API
Core
Text
IO / OS
Net
Encoding
Crypto
Compress / image / math
Database
External packages
UI
API
#crypto/ed25519
Xu 0.8.8 API
import: #crypto/ed25519
counts: 6 fns, 0 methods, 0 types, 4 consts, 0 ifaces
Ed25519 keys, sign, verify.
const public_key_size
pub const public_key_size = 32
Purpose
`crypto/ed25519`: GenerateKey / NewKeyFromSeed / Sign / Verify. Private key is 64 bytes (seed || public), public 32, signature 64. Curve arithmetic uses math/big ( uses crypto/internal/edwards25519). Field ops take p as an argument so scalarmult can hoist 2^255-19 and 2d. XU-CT-CLASS: variable-time XU-CT-USE: fixed-shape-only math/big curve arithmetic is variable-time; crypto/subtle covers only the final encoded-point equality check. Value `32`.
Parameters
none
const private_key_size
pub const private_key_size = 64
Purpose
Public constant `private_key_size`. Value `64`.
Parameters
none
const signature_size
pub const signature_size = 64
Purpose
Public constant `signature_size`. Value `64`.
Parameters
none
const seed_size
Purpose
Public constant `seed_size`. Value `32`.
Parameters
none
new_key_from_seed
pub fn new_key_from_seed(seed string ) string
Purpose
Construct key from seed. Throws on failure.
Parameters
seed string random seed (string)
Returns
string — result string
generate_key
pub fn generate_key() string
Purpose
Generate key. Throws on failure.
Parameters
none
Returns
string — result string
public
pub fn public(priv &string ) string
Purpose
public; returns string. Throws on failure.
Parameters
priv &string priv (borrowed; caller keeps it; type &string)
Returns
string — result string
seed
pub fn seed(priv &string ) string
Purpose
seed; returns string. Throws on failure.
Parameters
priv &string priv (borrowed; caller keeps it; type &string)
Returns
string — result string
sign
pub fn sign(private_key &string , message &string ) string
Purpose
Sign. Throws on failure.
Parameters
private_key &string private_key (borrowed; caller keeps it; type &string)
message &string message (borrowed; caller keeps it; type &string)
Returns
string — result string
verify
pub fn verify(public_key &string , message &string , sig &string ) bool
Purpose
Verify.
Parameters
public_key &string public_key (borrowed; caller keeps it; type &string)
message &string message (borrowed; caller keeps it; type &string)
sig &string sig (borrowed; caller keeps it; type &string)
Returns
bool — true or false