Ed25519-like signatures with X25519 keys, Axolotl-style.
Project description
Curve25519 signatures like in the early Axolotl
Rust
Import
use ed25519_axolotl::{
fast_signature,
full_signature,
decode_message,
random_bytes,
str_to_vec32,
vec32_to_str,
KeyPair
verify,
};
Generate New KeyPair
- the seed needs 32 bytes length or more
- if none, generate random keys
// seed: Vec<u32>
// let keys = KeyPair::new(Some(seed));
let keys = KeyPair::new(None);
println!("{}", keys);
Fast Signature
- 64 byte signature
- quick to sign and verify
- don't possible to decode signature back to message
let keys = KeyPair::new(None);
let msg = str_to_vec32("hello e25519 axolotl".to_string());
let signature = fast_signature(
keys.prvk,
msg.clone(),
Some(random_bytes(64))
);
Full Signature
- (64 + message length) byte signature
- slow to sign and verify
- it is possible to decode the signature back to the message
let keys = KeyPair::new(None);
let msg = str_to_vec32("hello e25519 axolotl".to_string());
let signature = full_signature(
keys.prvk,
msg.clone(),
Some(random_bytes(64))
);
Validate Signatures
- works with both fast and full signatures
let keys = KeyPair::new(None);
let msg = str_to_vec32("hello e25519 axolotl".to_string());
let signature_full = full_signature(
keys.prvk,
msg.clone(),
Some(random_bytes(64))
);
assert_eq!(true, validate_signature(keys.pubk, msg, signature_full));
let signature_fast = fast_signature(
keys.prvk,
msg.clone(),
Some(random_bytes(64))
);
assert_eq!(true, validate_signature(keys.pubk, msg, signature_fast));
Decode Message
- possible only for full_signature function
let keys = KeyPair::new(None);
let msg = str_to_vec32("hello e25519 axolotl".to_string());
let mut sign_msg = full_signature(
keys.prvk,
msg.clone(),
Some(random_bytes(64))
);
let decoded_msg = decode_message(keys.pubk, &mut sign_msg);
NodeJs (WebAssembly)
Import
import * as wasm from "ed25519_axolotl";
or
const wasm = require("ed25519_axolotl")
Generate New KeyPair
- the seed needs 32 bytes length or more
- if none, generate random keys
// const seed = wasm.stringToUint32Array("your seed with 32 bytes of length or more")
// const keys = new wasm.KeyPair(seed)
const keys = new wasm.KeyPair()
Fast Signature
- 64 byte signature
- quick to sign and verify
- don't possible to decode signature back to message
const keys = new wasm.KeyPair()
const msg = wasm.stringToUint32Array("hello lunes")
const signature = wasm.fastSignature(k.privateKey, msg, wasm.randomBytes(64))
Full Signature
- (64 + message length) byte signature
- slow to sign and verify
- it is possible to decode the signature back to the message
const keys = new wasm.KeyPair()
const msg = wasm.stringToUint32Array("hello lunes")
const signature = wasm.fullSignature(k.privateKey, msg, wasm.randomBytes(64))
Validate Signatures
- works with both fast and full signatures
const keys = new wasm.KeyPair()
const msg = wasm.stringToUint32Array("hello lunes")
const signatureFast = wasm.fastSignature(keys.privateKey, msg, wasm.randomBytes(64))
const validated = wasm.validateSignature(keys.publicKey, msg, signatureFast)
const signatureFull = wasm.fullSignature(keys.privateKey, msg, wasm.randomBytes(64))
const validated = wasm.validateSignature(keys.publicKey, msg, signatureFull)
Decode Message
- possible only for full_signature function
const keys = new wasm.KeyPair()
const msg = wasm.stringToUint32Array("hello lunes")
const signature = wasm.fullSignature(keys.privateKey, msg, wasm.randomBytes(64))
const dmsg = wasm.uint32ArrayToString(
wasm.decode_message(keys.publiKey, signature)
)
Python (Cython)
Import
from ed25519_axolotl import KeyPair
from ed25519_axolotl import (
validate_signature,
fast_signature,
full_signature,
decode_message
)
Generate New KeyPair
- the seed needs 32 bytes length or more
- if none, generate random keys
# seed: bytes = [i for i in range(32)]
# keys = KeyPair( seed )
keys = KeyPair()
keys.private_key
keys.public_key
Fast Signature
- 64 byte signature
- quick to sign and verify
- don't possible to decode signature back to message
keys = KeyPair()
message = b"hello lunes"
signature = fast_signature(keys.private_key, message, random_bytes(64))
Full Signature
- (64 + message length) byte signature
- slow to sign and verify
- it is possible to decode the signature back to the message
keys = KeyPair()
message = b"hello lunes"
signature_full = full_signature(keys.private_key, message, random_bytes(64))
Validate Signatures
- works with both fast and full signatures
keys = KeyPair()
msg = b"hello lunes"
signatureFast = fast_signature(k.private_key, msg, random_bytes(64))
validated = validate_signature(keys.public_key, msg, signature_fast)
signatureFull = fullSignature(k.private_key, msg, random_bytes(64))
validated = validate_signature(keys.public_key, msg, signature_full)
Decode Message
- possible only for full_signature function
keys = KeyPair()
message = b"hello lunes"
signature_full = full_signature(keys.private_key, message, random_bytes(64))
decode_msg = decode_message(keys.public_key, signature_full)
like_string_msg = ''.join(map(chr, decode_msg)))
like_bytes_msg = bytes(decode_msg)
like_list_int_msg = decode_msg
Credits
- Ported to Rust by Miguel Sandro Lucero, miguel.sandro@gmail.com, 2021.09.11, see here
- Curve25519 signatures idea and math by Trevor Perrin, see here
- Derived from axlsign.js written by Dmitry Chestnykh, see here
- You can use it under MIT.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
File details
Details for the file ed25519_axolotl-1.7.0-pp37-pypy37_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.whl
.
File metadata
- Download URL: ed25519_axolotl-1.7.0-pp37-pypy37_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.whl
- Upload date:
- Size: 229.9 kB
- Tags: PyPy, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.12.10-beta.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 76caa1f6c19db44ca251d5fc1785622fd52d37195362e523835a95cfaad4006e |
|
MD5 | d41c277b9ed55527947739dbf40253ad |
|
BLAKE2b-256 | 846705f409cffc235cd0ea94d530bf8267190637daf010cfe71ddeb95239fa2b |
File details
Details for the file ed25519_axolotl-1.7.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.whl
.
File metadata
- Download URL: ed25519_axolotl-1.7.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.whl
- Upload date:
- Size: 230.1 kB
- Tags: CPython 3.10, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.12.10-beta.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 769358fcc7bab9e91e11fac50e7502611208b719f27f77836bc0e08169b00140 |
|
MD5 | ed9680109e50fa127d2658c93cf5f26e |
|
BLAKE2b-256 | fae8564564dc15a5e06922528b76b4c56382eaeb975f0cb68b0ab0dc3815c9a5 |
File details
Details for the file ed25519_axolotl-1.7.0-cp39-cp39-manylinux_2_28_aarch64.whl
.
File metadata
- Download URL: ed25519_axolotl-1.7.0-cp39-cp39-manylinux_2_28_aarch64.whl
- Upload date:
- Size: 209.0 kB
- Tags: CPython 3.9, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.12.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8024223ae7a1577dbd70b45cfb874f9befae8ab0edd39171408ddfa5fbff4d6e |
|
MD5 | 2daa3b40a4d6c0f2e0cb6101491da569 |
|
BLAKE2b-256 | 3b8a578e2d36ef0538913fbc2c12703f15be9f883d510e9aba82ef6826546d1f |
File details
Details for the file ed25519_axolotl-1.7.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl
.
File metadata
- Download URL: ed25519_axolotl-1.7.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl
- Upload date:
- Size: 230.1 kB
- Tags: CPython 3.9, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.12.10-beta.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c8d8a6bbb3ba7e7de651d4a5cf8669f5a3d80d328747055e6af231a2c8f036f1 |
|
MD5 | 19cf21dfcdde25eceefaacf672090fd7 |
|
BLAKE2b-256 | 86e6a9c51f97e12c5a19ad7e9582d5c070de847e54d9fe67e0680d0e05957fe3 |
File details
Details for the file ed25519_axolotl-1.7.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl
.
File metadata
- Download URL: ed25519_axolotl-1.7.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl
- Upload date:
- Size: 229.8 kB
- Tags: CPython 3.8, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.12.10-beta.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b8c9c4658d30ccaaff42f71e9d9d9478741df3fcb6bf29aad46e8527304904a1 |
|
MD5 | 23cbf37dc5fc98daa147a03793553f31 |
|
BLAKE2b-256 | eae48e2f4454fad919c2564630f9db5bc28a585b7256137f34c72e9e394bd162 |
File details
Details for the file ed25519_axolotl-1.7.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
.
File metadata
- Download URL: ed25519_axolotl-1.7.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
- Upload date:
- Size: 229.8 kB
- Tags: CPython 3.7m, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.12.10-beta.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 06cae337a6472462a3f96420bc49fb9a086e420c3c564140a25ccf1f69b62ac7 |
|
MD5 | 7a3e591a4afdc79bc17aed569e3e6329 |
|
BLAKE2b-256 | bc1b82bd1cf469c376c8de29a4d9bbb0bc48a1e8add0424293793362072f0c9d |