|
| 1 | +// SPDX-License-Identifier: CC0-1.0 |
| 2 | + |
| 3 | +//! Constants related to the API and the underlying curve. |
| 4 | +//! |
| 5 | + |
| 6 | +/// The size (in bytes) of a message. |
| 7 | +pub const message_size: usize = 32; |
| 8 | + |
| 9 | +/// the size (in bytes) of a secret key. |
| 10 | +pub const secret_key_size: usize = 32; |
| 11 | + |
| 12 | +/// the size (in bytes) of a serialized public key. |
| 13 | +pub const public_key_size: usize = 33; |
| 14 | + |
| 15 | +/// the size (in bytes) of an serialized uncompressed public key. |
| 16 | +pub const uncompressed_public_key_size: usize = 65; |
| 17 | + |
| 18 | +/// the maximum size of a signature. |
| 19 | +pub const max_signature_size: usize = 72; |
| 20 | + |
| 21 | +/// the maximum size of a compact signature. |
| 22 | +pub const compact_signature_size: usize = 64; |
| 23 | + |
| 24 | +/// the size of a schnorr signature. |
| 25 | +pub const schnorr_signature_size: usize = 64; |
| 26 | + |
| 27 | +/// the size of a schnorr public key. |
| 28 | +pub const schnorr_public_key_size: usize = 32; |
| 29 | + |
| 30 | +/// the size of a key pair. |
| 31 | +pub const key_pair_size: usize = 96; |
| 32 | + |
| 33 | +/// the size of a full elligatorswift encoding. |
| 34 | +pub const ellswift_encoding_size: usize = 64; |
| 35 | + |
| 36 | +/// The Prime for the secp256k1 field element. |
| 37 | +pub const field_size: [32]u8 = .{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x2f }; |
| 38 | + |
| 39 | +/// the order of the secp256k1 curve. |
| 40 | +pub const curve_order: [32]u8 = .{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0, 0x3b, 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41, 0x41 }; |
| 41 | + |
| 42 | +/// the x coordinate of the generator. |
| 43 | +pub const generator_x: [32]u8 = .{ 0x79, 0xbe, 0x66, 0x7e, 0xf9, 0xdc, 0xbb, 0xac, 0x55, 0xa0, 0x62, 0x95, 0xce, 0x87, 0x0b, 0x07, 0x02, 0x9b, 0xfc, 0xdb, 0x2d, 0xce, 0x28, 0xd9, 0x59, 0xf2, 0x81, 0x5b, 0x16, 0xf8, 0x17, 0x98 }; |
| 44 | + |
| 45 | +/// the y coordinate of the generator. |
| 46 | +pub const generator_y: [32]u8 = .{ 0x48, 0x3a, 0xda, 0x77, 0x26, 0xa3, 0xc4, 0x65, 0x5d, 0xa4, 0xfb, 0xfc, 0x0e, 0x11, 0x08, 0xa8, 0xfd, 0x17, 0xb4, 0x48, 0xa6, 0x85, 0x54, 0x19, 0x9c, 0x47, 0xd0, 0x8f, 0xfb, 0x10, 0xd4, 0xb8 }; |
| 47 | + |
| 48 | +/// the value zero as an array of bytes. |
| 49 | +pub const zero: [32]u8 = [_]u8{0} ** 32; |
| 50 | + |
| 51 | +/// the value one as big-endian array of bytes. |
| 52 | +pub const one: [32]u8 = .{ |
| 53 | + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, |
| 54 | +}; |
0 commit comments