Skip to content
FutureBlitz

    Install

    Import std.crypto.signatures

    EcdsaP256

    std.crypto.signatures

    struct

    Public Struct EcdsaP256

    ECDSA on NIST's P-256 with SHA-256 (ES256): a private key is 32 bytes, a public key its point, uncompressed, 65 bytes, and a signature r then s, 64 bytes.

    Examples

    Local privateKey = EcdsaP256.NewPrivateKey()
    Local publicKey = EcdsaP256.PublicKeyOf(privateKey)
    Expect(publicKey.Count == 65)
    Local signature = EcdsaP256.Sign(privateKey, "a message")
    Expect(EcdsaP256.Verify(publicKey, "a message", signature))

    std/crypto/signatures.fb, line 100

    • Public Static Method NewPrivateKey(): UInt8[] static method #

      A new random private key.

    • @PanicsAtCaller Public Static Method PublicKeyOf(privateKey: UInt8[]): UInt8[] static method #

      privateKey's public key. Panics unless privateKey is a P-256 private key.

    • @PanicsAtCaller Public Static Method Sign(privateKey: UInt8[], message: UInt8[]): UInt8[] static method #

      message's signature with privateKey, deterministic, as RFC 6979 makes it, so it needs no random number. Panics unless privateKey is a P-256 private key.

    • @PanicsAtCaller Public Static Method Sign(privateKey: UInt8[], text: String): UInt8[] static method #

      text's signature, by its UTF-8 bytes, with privateKey. Panics unless privateKey is 32 bytes, a number from 1 up to the curve's order.

    • Public Static Method Verify(publicKey: UInt8[], message: UInt8[], signature: UInt8[]): Bool static method #

      Whether signature is publicKey's of message.

    • Public Static Method Verify(publicKey: UInt8[], text: String, signature: UInt8[]): Bool static method #

      Whether signature is publicKey's of text's UTF-8 bytes.

    Report an issue with this page or with FutureBlitz on GitHub.