secp256k1/
constants.rs

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.
7pub const MESSAGE_SIZE: usize = 32;
8
9/// The size (in bytes) of a secret key.
10pub const SECRET_KEY_SIZE: usize = 32;
11
12/// The size (in bytes) of a serialized public key.
13pub const PUBLIC_KEY_SIZE: usize = 33;
14
15/// The size (in bytes) of an serialized uncompressed public key.
16pub const UNCOMPRESSED_PUBLIC_KEY_SIZE: usize = 65;
17
18/// The maximum size of a signature.
19pub const MAX_SIGNATURE_SIZE: usize = 72;
20
21/// The maximum size of a compact signature.
22pub const COMPACT_SIGNATURE_SIZE: usize = 64;
23
24/// The size of a schnorr signature.
25pub const SCHNORR_SIGNATURE_SIZE: usize = 64;
26
27/// The size of a schnorr public key.
28pub const SCHNORR_PUBLIC_KEY_SIZE: usize = 32;
29
30/// The size of a key pair.
31pub const KEY_PAIR_SIZE: usize = 96;
32
33/// The size of a full ElligatorSwift encoding.
34pub const ELLSWIFT_ENCODING_SIZE: usize = 64;
35
36/// The Prime for the secp256k1 field element.
37#[rustfmt::skip]
38pub const FIELD_SIZE: [u8; 32] = [
39    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
40    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
41    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
42    0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x2f
43];
44
45/// The order of the secp256k1 curve.
46#[rustfmt::skip]
47pub const CURVE_ORDER: [u8; 32] = [
48    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
49    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe,
50    0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0, 0x3b,
51    0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41, 0x41
52];
53
54/// The X coordinate of the generator.
55#[rustfmt::skip]
56pub const GENERATOR_X: [u8; 32] = [
57    0x79, 0xbe, 0x66, 0x7e, 0xf9, 0xdc, 0xbb, 0xac,
58    0x55, 0xa0, 0x62, 0x95, 0xce, 0x87, 0x0b, 0x07,
59    0x02, 0x9b, 0xfc, 0xdb, 0x2d, 0xce, 0x28, 0xd9,
60    0x59, 0xf2, 0x81, 0x5b, 0x16, 0xf8, 0x17, 0x98
61];
62
63/// The Y coordinate of the generator.
64#[rustfmt::skip]
65pub const GENERATOR_Y: [u8; 32] = [
66    0x48, 0x3a, 0xda, 0x77, 0x26, 0xa3, 0xc4, 0x65,
67    0x5d, 0xa4, 0xfb, 0xfc, 0x0e, 0x11, 0x08, 0xa8,
68    0xfd, 0x17, 0xb4, 0x48, 0xa6, 0x85, 0x54, 0x19,
69    0x9c, 0x47, 0xd0, 0x8f, 0xfb, 0x10, 0xd4, 0xb8
70];
71
72/// The value zero as an array of bytes.
73pub const ZERO: [u8; 32] = [0; 32];
74
75/// The value one as big-endian array of bytes.
76pub const ONE: [u8; 32] = [
77    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,
78];