core/crypto/ed25519
ed25519
Types
2Private_Key
Private_Key :: struct {
// WARNING: All of the members are to be treated as internal (ie:
// the Private_Key structure is intended to be opaque). There are
// subtle vulnerabilities that can be introduced if the internal
// values are allowed to be altered.
//
// See: https://github.com/MystenLabs/ed25519-unsafe-libs
_b: [32]u8,
_s: grp.Scalar,
_hdigest2: [HDIGEST2_SIZE]u8,
_pub_key: Public_Key,
_is_initialized: bool,
}SourcePrivate_Key is an Ed25519 private key.
Public_Key
Public_Key :: struct {
// WARNING: All of the members are to be treated as internal (ie:
// the Public_Key structure is intended to be opaque).
_b: [32]u8,
_neg_A: grp.Group_Element,
_is_valid: bool,
_is_initialized: bool,
}SourcePublic_Key is an Ed25519 public key.
Constants
3PRIVATE_KEY_SIZE
PRIVATE_KEY_SIZE :: 32SourcePRIVATE_KEY_SIZE is the byte-encoded private key size.
PUBLIC_KEY_SIZE
PUBLIC_KEY_SIZE :: 32SourcePUBLIC_KEY_SIZE is the byte-encoded public key size.
SIGNATURE_SIZE
SIGNATURE_SIZE :: 64SourceSIGNATURE_SIZE is the byte-encoded signature size.
Procedures
14private_key_bytes
private_key_bytes :: proc(priv_key: ^Private_Key, dst: []u8)Sourceprivate_key_bytes sets dst to byte-encoding of priv_key.
private_key_clear
private_key_clear :: proc(priv_key: ^Private_Key)Sourceprivate_key_clear clears priv_key to the uninitialized state.
private_key_generate
private_key_generate :: proc(priv_key: ^Private_Key) -> (bool)Sourceprivate_key_generate uses the system entropy source to generate a new Private_Key. This will only fail if and only if (⟺) the system entropy source is missing or broken.
private_key_public_bytes
private_key_public_bytes :: proc(priv_key: ^Private_Key, dst: []u8)Sourceprivate_key_public_bytes sets dst to the byte-encoding of the public key corresponding to priv_key.
private_key_set
private_key_set :: proc(priv_key: ^Private_Key, src: ^Private_Key)Sourceprivate_key_set sets priv_key to src.
private_key_set_bytes
private_key_set_bytes :: proc(priv_key: ^Private_Key, b: []u8) -> (bool)Sourceprivate_key_set_bytes decodes a byte-encoded private key, and returns true if and only if (⟺) the operation was successful.
public_key_bytes
public_key_bytes :: proc(pub_key: ^Public_Key, dst: []u8)Sourcepublic_key_bytes sets dst to byte-encoding of pub_key.
public_key_clear
public_key_clear :: proc(pub_key: ^Public_Key)Sourcepublic_key_clear clears pub_key to the uninitialized state.
public_key_equal
public_key_equal :: proc(pub_key: ^Public_Key, other: ^Public_Key) -> (bool)Sourcepublic_key_equal returns true if and only if (⟺) pub_key is equal to other.
public_key_set
public_key_set :: proc(pub_key: ^Public_Key, src: ^Public_Key)Sourcepublic_key_set sets pub_key to src.
public_key_set_bytes
public_key_set_bytes :: proc(pub_key: ^Public_Key, b: []u8) -> (bool)Sourcepublic_key_set_bytes decodes a byte-encoded public key, and returns true if and only if (⟺) the operation was successful.
public_key_set_priv
public_key_set_priv :: proc(pub_key: ^Public_Key, priv_key: ^Private_Key)Sourcepublic_key_set_priv sets pub_key to the public component of priv_key.
sign
sign :: proc(priv_key: ^Private_Key, msg: []u8, sig: []u8)Sourcesign writes the signature by priv_key over msg to sig.
verify
verify :: proc(pub_key: ^Public_Key, msg: []u8, sig: []u8, allow_small_order_A: untyped boolean = false) -> (bool)Sourceverify returns true if and only if (⟺) sig is a valid signature by pub_key over msg.
The optional allow_small_order_A parameter will make this implementation strictly compatible with FIPS 186-5, at the expense of SBS-security. Doing so is NOT recommended, and the disallowed public keys all have a known discrete-log.