structstd.crypto.ecdsa.Ecdsa.PublicKey[src]

An ECDSA public key.

Fields

p: Curve

Values

Constantcompressed_sec1_encoded_length[src]

Length (in bytes) of a compressed sec1-encoded key.

Source Code

Source code
pub const compressed_sec1_encoded_length = 1 + Curve.Fe.encoded_length

Constantuncompressed_sec1_encoded_length[src]

Length (in bytes) of a compressed sec1-encoded key.

Source Code

Source code
pub const uncompressed_sec1_encoded_length = 1 + 2 * Curve.Fe.encoded_length

Functions

FunctionfromSec1[src]

pub fn fromSec1(sec1: []const u8) !PublicKey

Create a public key from a SEC-1 representation.

Parameters

sec1: []const u8

Source Code

Source code
pub fn fromSec1(sec1: []const u8) !PublicKey {
    return PublicKey{ .p = try Curve.fromSec1(sec1) };
}

FunctiontoCompressedSec1[src]

pub fn toCompressedSec1(pk: PublicKey) [compressed_sec1_encoded_length]u8

Encode the public key using the compressed SEC-1 format.

Parameters

Source Code

Source code
pub fn toCompressedSec1(pk: PublicKey) [compressed_sec1_encoded_length]u8 {
    return pk.p.toCompressedSec1();
}

FunctiontoUncompressedSec1[src]

pub fn toUncompressedSec1(pk: PublicKey) [uncompressed_sec1_encoded_length]u8

Encoding the public key using the uncompressed SEC-1 format.

Parameters

Source Code

Source code
pub fn toUncompressedSec1(pk: PublicKey) [uncompressed_sec1_encoded_length]u8 {
    return pk.p.toUncompressedSec1();
}

Source Code

Source code
pub const PublicKey = struct {
    /// Length (in bytes) of a compressed sec1-encoded key.
    pub const compressed_sec1_encoded_length = 1 + Curve.Fe.encoded_length;
    /// Length (in bytes) of a compressed sec1-encoded key.
    pub const uncompressed_sec1_encoded_length = 1 + 2 * Curve.Fe.encoded_length;

    p: Curve,

    /// Create a public key from a SEC-1 representation.
    pub fn fromSec1(sec1: []const u8) !PublicKey {
        return PublicKey{ .p = try Curve.fromSec1(sec1) };
    }

    /// Encode the public key using the compressed SEC-1 format.
    pub fn toCompressedSec1(pk: PublicKey) [compressed_sec1_encoded_length]u8 {
        return pk.p.toCompressedSec1();
    }

    /// Encoding the public key using the uncompressed SEC-1 format.
    pub fn toUncompressedSec1(pk: PublicKey) [uncompressed_sec1_encoded_length]u8 {
        return pk.p.toUncompressedSec1();
    }
}