This module implements ED25519. This code is a port of the public domain, "ref10" implementation of ed25519 from SUPERCOP.
Types
EdKeyPair = object seckey*: EdPrivateKey pubkey*: EdPublicKey
- Source Edit
EdPrivateKey = object data*: array[EdPrivateKeySize, byte]
- Source Edit
EdPublicKey = object data*: array[EdPublicKeySize, byte]
- Source Edit
EdSignature = object data*: array[EdSignatureSize, byte]
- Source Edit
Consts
EdPrivateKeySize = 64
- Size in octets (bytes) of serialized ED25519 private key. Source Edit
EdPublicKeySize = 32
- Size in octets (bytes) of serialized ED25519 public key. Source Edit
EdSignatureSize = 64
- Size in octets (bytes) of serialized ED25519 signature. Source Edit
Procs
proc `$`(key: EdPrivateKey): string {....raises: [], tags: [], forbids: [].}
- Return string representation of ED25519 private key. Source Edit
proc `$`(key: EdPublicKey): string {....raises: [], tags: [], forbids: [].}
- Return string representation of ED25519 private key. Source Edit
proc `$`(sig: EdSignature): string {....raises: [], tags: [], forbids: [].}
- Return string representation of ED25519 signature. Source Edit
proc `==`(eda, edb: EdPrivateKey): bool {....raises: [], tags: [], forbids: [].}
- Compare ED25519 private key objects for equality. Source Edit
proc `==`(eda, edb: EdPublicKey): bool {....raises: [], tags: [], forbids: [].}
- Compare ED25519 public key objects for equality. Source Edit
proc `==`(eda, edb: EdSignature): bool {....raises: [], tags: [], forbids: [].}
- Compare ED25519 signature objects for equality. Source Edit
proc checkScalar(scalar: openArray[byte]): uint32 {....raises: [], tags: [], forbids: [].}
- Source Edit
proc clear(key: var EdPrivateKey) {....raises: [], tags: [], forbids: [].}
- Wipe and clear memory of ED25519 private key. Source Edit
proc clear(key: var EdPublicKey) {....raises: [], tags: [], forbids: [].}
- Wipe and clear memory of ED25519 public key. Source Edit
proc clear(pair: var EdKeyPair) {....raises: [], tags: [], forbids: [].}
- Wipe and clear memory of ED25519 key pair. Source Edit
proc clear(sig: var EdSignature) {....raises: [], tags: [], forbids: [].}
- Wipe and clear memory of ED25519 signature. Source Edit
proc getBytes(key: EdPrivateKey): seq[byte] {....raises: [], tags: [], forbids: [].}
- Serialize ED25519 private key and return it. Source Edit
proc getBytes(key: EdPublicKey): seq[byte] {....raises: [], tags: [], forbids: [].}
- Serialize ED25519 public key and return it. Source Edit
proc getBytes(sig: EdSignature): seq[byte] {....raises: [], tags: [], forbids: [].}
- Serialize ED25519 signature and return it. Source Edit
proc getPublicKey(key: EdPrivateKey): EdPublicKey {....raises: [], tags: [], forbids: [].}
- Calculate and return ED25519 public key from private key key. Source Edit
proc init(key: var EdPrivateKey; data: openArray[byte]): bool {....raises: [], tags: [], forbids: [].}
-
Initialize ED25519 private key key from raw binary representation data.
Procedure returns true on success.
Source Edit proc init(key: var EdPrivateKey; data: string): bool {....raises: [], tags: [], forbids: [].}
-
Initialize ED25519 private key key from hexadecimal string representation data.
Procedure returns true on success.
Source Edit proc init(key: var EdPublicKey; data: openArray[byte]): bool {....raises: [], tags: [], forbids: [].}
-
Initialize ED25519 public key key from raw binary representation data.
Procedure returns true on success.
Source Edit proc init(key: var EdPublicKey; data: string): bool {....raises: [], tags: [], forbids: [].}
-
Initialize ED25519 public key key from hexadecimal string representation data.
Procedure returns true on success.
Source Edit proc init(sig: var EdSignature; data: openArray[byte]): bool {....raises: [], tags: [], forbids: [].}
-
Initialize ED25519 signature sig from raw binary representation data.
Procedure returns true on success.
Source Edit proc init(sig: var EdSignature; data: string): bool {....raises: [], tags: [], forbids: [].}
-
Initialize ED25519 signature sig from hexadecimal string representation data.
Procedure returns true on success.
Source Edit proc init(t: typedesc[EdPrivateKey]; data: openArray[byte]): Result[ EdPrivateKey, EdError] {....raises: [].}
- Initialize ED25519 private key from raw binary representation data and return constructed object. Source Edit
proc init(t: typedesc[EdPrivateKey]; data: string): Result[EdPrivateKey, EdError] {. ...raises: [].}
- Initialize ED25519 private key from hexadecimal string representation data and return constructed object. Source Edit
proc init(t: typedesc[EdPublicKey]; data: openArray[byte]): Result[EdPublicKey, EdError] {....raises: [].}
- Initialize ED25519 public key from raw binary representation data and return constructed object. Source Edit
proc init(t: typedesc[EdPublicKey]; data: string): Result[EdPublicKey, EdError] {. ...raises: [].}
- Initialize ED25519 public key from hexadecimal string representation data and return constructed object. Source Edit
proc init(t: typedesc[EdSignature]; data: openArray[byte]): Result[EdSignature, EdError] {....raises: [].}
- Initialize ED25519 signature from raw binary representation data and return constructed object. Source Edit
proc init(t: typedesc[EdSignature]; data: string): Result[EdSignature, EdError] {. ...raises: [].}
- Initialize ED25519 signature from hexadecimal string representation data and return constructed object. Source Edit
proc random(t: typedesc[EdKeyPair]; rng: var HmacDrbgContext): EdKeyPair {. ...raises: [].}
- Generate new random ED25519 private and public keypair using OS specific CSPRNG. Source Edit
proc random(t: typedesc[EdPrivateKey]; rng: var HmacDrbgContext): EdPrivateKey {. ...raises: [].}
- Generate new random ED25519 private key using the given random number generator Source Edit
proc sign[T: byte | char](key: EdPrivateKey; message: openArray[T]): EdSignature {. ...gcsafe, noinit, ...raises: [].}
- Create ED25519 signature of data message using private key key. Source Edit
proc toBytes(key: EdPrivateKey; data: var openArray[byte]): int {....raises: [], tags: [], forbids: [].}
-
Serialize ED25519 private key key to raw binary form and store it to data.
Procedure returns number of bytes (octets) needed to store ED25519 private key.
Source Edit proc toBytes(key: EdPublicKey; data: var openArray[byte]): int {....raises: [], tags: [], forbids: [].}
-
Serialize ED25519 public key key to raw binary form and store it to data.
Procedure returns number of bytes (octets) needed to store ED25519 public key.
Source Edit proc toBytes(sig: EdSignature; data: var openArray[byte]): int {....raises: [], tags: [], forbids: [].}
-
Serialize ED25519 signature sig to raw binary form and store it to data.
Procedure returns number of bytes (octets) needed to store ED25519 signature.
Source Edit proc verify[T: byte | char](sig: EdSignature; message: openArray[T]; key: EdPublicKey): bool {....raises: [].}
-
Verify ED25519 signature sig using public key key and data message.
Return true if message verification succeeded, false if verification failed.
Source Edit