|
1 | 1 | use crate::ops::{Add, Sub, Mul, Div, Rem,}; |
2 | 2 |
|
| 3 | + |
| 4 | +global bn254_fq = [0x47, 0xFD, 0x7C, 0xD8, 0x16, 0x8C, 0x20, 0x3C, 0x8d, 0xca, 0x71, 0x68, 0x91, 0x6a, 0x81, 0x97, |
| 5 | + 0x5d, 0x58, 0x81, 0x81, 0xb6, 0x45, 0x50, 0xb8, 0x29, 0xa0, 0x31, 0xe1, 0x72, 0x4e, 0x64, 0x30]; |
| 6 | +global bn254_fr = [0x01, 0x00, 0x00, 0x00, 0x3F, 0x59, 0x1F, 0x43, 0x09, 0x97, 0xB9, 0x79, 0x48, 0xE8, 0x33, 0x28, |
| 7 | + 0x5D, 0x58, 0x81, 0x81, 0xB6, 0x45, 0x50, 0xB8, 0x29, 0xA0, 0x31, 0xE1, 0x72, 0x4E, 0x64, 0x30]; |
| 8 | +global secpk1_fr = [0x41, 0x41, 0x36, 0xD0, 0x8C, 0x5E, 0xD2, 0xBF, 0x3B, 0xA0, 0x48, 0xAF, 0xE6, 0xDC, 0xAE, 0xBA, |
| 9 | + 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]; |
| 10 | +global secpk1_fq = [0x2F, 0xFC, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, |
| 11 | + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]; |
| 12 | +global secpr1_fq = [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, |
| 13 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF]; |
| 14 | +global secpr1_fr = [0x51, 0x25, 0x63, 0xFC, 0xC2, 0xCA, 0xB9, 0xF3, 0x84, 0x9E, 0x17, 0xA7, 0xAD, 0xFA, 0xE6, 0xBC, |
| 15 | + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,0xFF, 0xFF, 0xFF, 0xFF]; |
| 16 | + |
| 17 | + |
3 | 18 | struct BigInt { |
4 | 19 | pointer: u32, |
5 | 20 | modulus: u32, |
6 | 21 | } |
7 | 22 |
|
8 | 23 | impl BigInt { |
9 | 24 | #[builtin(bigint_add)] |
10 | | - pub fn bigint_add(self, other: BigInt) -> BigInt { |
| 25 | + fn bigint_add(self, other: BigInt) -> BigInt { |
11 | 26 | } |
12 | 27 | #[builtin(bigint_neg)] |
13 | | - pub fn bigint_neg(self, other: BigInt) -> BigInt { |
| 28 | + fn bigint_neg(self, other: BigInt) -> BigInt { |
14 | 29 | } |
15 | 30 | #[builtin(bigint_mul)] |
16 | | - pub fn bigint_mul(self, other: BigInt) -> BigInt { |
| 31 | + fn bigint_mul(self, other: BigInt) -> BigInt { |
17 | 32 | } |
18 | 33 | #[builtin(bigint_div)] |
19 | | - pub fn bigint_div(self, other: BigInt) -> BigInt { |
| 34 | + fn bigint_div(self, other: BigInt) -> BigInt { |
20 | 35 | } |
21 | 36 | #[builtin(bigint_from_le_bytes)] |
22 | | - pub fn from_le_bytes(bytes: [u8], modulus: [u8]) -> BigInt {} |
| 37 | + fn from_le_bytes(bytes: [u8], modulus: [u8]) -> BigInt {} |
23 | 38 | #[builtin(bigint_to_le_bytes)] |
24 | 39 | pub fn to_le_bytes(self) -> [u8] {} |
| 40 | + |
| 41 | + pub fn bn254_fr_from_le_bytes(bytes: [u8]) -> BigInt { |
| 42 | + BigInt::from_le_bytes(bytes, bn254_fr) |
| 43 | + } |
| 44 | + pub fn bn254_fq_from_le_bytes(bytes: [u8]) -> BigInt { |
| 45 | + BigInt::from_le_bytes(bytes, bn254_fq) |
| 46 | + } |
| 47 | + pub fn secpk1_fq_from_le_bytes(bytes: [u8]) -> BigInt { |
| 48 | + BigInt::from_le_bytes(bytes, secpk1_fq) |
| 49 | + } |
| 50 | + pub fn secpk1_fr_from_le_bytes(bytes: [u8]) -> BigInt { |
| 51 | + BigInt::from_le_bytes(bytes, secpk1_fr) |
| 52 | + } |
25 | 53 | } |
26 | 54 |
|
27 | 55 | impl Add for BigInt { |
|
0 commit comments