-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathlib.rs
More file actions
159 lines (116 loc) · 6.13 KB
/
Copy pathlib.rs
File metadata and controls
159 lines (116 loc) · 6.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
//! Wrapper syscall API for the Pico patches.
pub mod bls12381;
pub mod bn254;
pub mod ecdsa;
pub mod ed25519;
pub mod io;
pub mod secp256k1;
pub mod secp256r1;
pub mod unconstrained;
pub mod utils;
pub mod verify;
/// Enum representing the different Precompile Poseidon2 permutation syscall types.
#[repr(u32)]
pub enum SyscallType {
BabyBear = 0,
KoalaBear = 1,
M31 = 2,
}
extern "C" {
/// Halts the program with the given exit code.
pub fn syscall_halt(exit_code: u8) -> !;
/// Writes the bytes in the given buffer to the given file descriptor.
pub fn syscall_write(fd: u32, write_buf: *const u8, nbytes: usize);
/// Reads the bytes from the given file descriptor into the given buffer.
pub fn syscall_read(fd: u32, read_buf: *mut u8, nbytes: usize);
/// Executes the SHA-256 extend operation on the given word array.
/// Each logical SHA word is taken from the low 32 bits of one 8-byte-aligned `u64` slot.
pub fn syscall_sha256_extend(w: *mut [u64; 64]);
/// Executes the SHA-256 compress operation on the given word array and a given state.
/// Each logical SHA word is taken from the low 32 bits of one 8-byte-aligned `u64` slot.
pub fn syscall_sha256_compress(w: *mut [u64; 64], state: *mut [u64; 8]);
/// Executes an Ed25519 curve addition on the given points.
pub fn syscall_ed_add(p: *mut [u64; 8], q: *const [u64; 8]);
/// Executes an Ed25519 curve decompression on the given point.
pub fn syscall_ed_decompress(point: &mut [u64; 8]);
/// Executes an Sepc256k1 curve addition on the given points.
pub fn syscall_secp256k1_add(p: *mut [u64; 8], q: *const [u64; 8]);
/// Executes an Secp256k1 curve doubling on the given point.
pub fn syscall_secp256k1_double(p: *mut [u64; 8]);
/// Executes an Secp256k1 curve decompression on the given point.
pub fn syscall_secp256k1_decompress(point: &mut [u64; 8], is_odd: bool);
/// Executes an Secp256r1 curve addition on the given points.
pub fn syscall_secp256r1_add(p: *mut [u64; 8], q: *const [u64; 8]);
/// Executes an Secp256r1 curve doubling on the given point.
pub fn syscall_secp256r1_double(p: *mut [u64; 8]);
/// Executes an Secp256r1 curve decompression on the given point.
pub fn syscall_secp256r1_decompress(point: &mut [u64; 8], is_odd: bool);
/// Executes a Bn254 curve addition on the given points.
pub fn syscall_bn254_add(p: *mut [u64; 8], q: *const [u64; 8]);
/// Executes a Bn254 curve doubling on the given point.
pub fn syscall_bn254_double(p: *mut [u64; 8]);
/// Executes a BLS12-381 curve addition on the given points.
pub fn syscall_bls12381_add(p: *mut [u64; 12], q: *const [u64; 12]);
/// Executes a BLS12-381 curve doubling on the given point.
pub fn syscall_bls12381_double(p: *mut [u64; 12]);
/// Executes the Keccak-256 permutation on the given state.
pub fn syscall_keccak_permute(state: *mut [u64; 25]);
/// Executes an uint256 multiplication on the given inputs.
pub fn syscall_uint256_mulmod(x: *mut [u64; 4], y: *const [u64; 4]);
/// Enters unconstrained mode.
pub fn syscall_enter_unconstrained() -> bool;
/// Exits unconstrained mode.
pub fn syscall_exit_unconstrained();
/// Defers the verification of a valid Pico zkVM proof.
pub fn syscall_verify_pico_proof(vk_digest: &[u32; 8], pv_digest: &[u8; 32]);
/// Returns the length of the next element in the hint stream.
pub fn syscall_hint_len() -> usize;
/// Reads the next element in the hint stream into the given buffer.
pub fn syscall_hint_read(ptr: *mut u8, len: usize);
/// Allocates a buffer aligned to the given alignment.
pub fn sys_alloc_aligned(bytes: usize, align: usize) -> *mut u8;
/// Decompresses a BLS12-381 point.
pub fn syscall_bls12381_decompress(point: &mut [u64; 12], is_odd: bool);
/// Computes a big integer operation with a modulus.
pub fn sys_bigint(
result: *mut [u64; 4],
op: u64,
x: *const [u64; 4],
y: *const [u64; 4],
modulus: *const [u64; 4],
);
/// Executes a BLS12-381 field addition on the given inputs.
pub fn syscall_bls12381_fp_addmod(p: *mut u64, q: *const u64);
/// Executes a BLS12-381 field subtraction on the given inputs.
pub fn syscall_bls12381_fp_submod(p: *mut u64, q: *const u64);
/// Executes a BLS12-381 field multiplication on the given inputs.
pub fn syscall_bls12381_fp_mulmod(p: *mut u64, q: *const u64);
/// Executes a BLS12-381 Fp2 addition on the given inputs.
pub fn syscall_bls12381_fp2_addmod(p: *mut u64, q: *const u64);
/// Executes a BLS12-381 Fp2 subtraction on the given inputs.
pub fn syscall_bls12381_fp2_submod(p: *mut u64, q: *const u64);
/// Executes a BLS12-381 Fp2 multiplication on the given inputs.
pub fn syscall_bls12381_fp2_mulmod(p: *mut u64, q: *const u64);
/// Executes a BN254 field addition on the given inputs.
pub fn syscall_bn254_fp_addmod(p: *mut u64, q: *const u64);
/// Executes a BN254 field subtraction on the given inputs.
pub fn syscall_bn254_fp_submod(p: *mut u64, q: *const u64);
/// Executes a BN254 field multiplication on the given inputs.
pub fn syscall_bn254_fp_mulmod(p: *mut u64, q: *const u64);
/// Executes a BN254 Fp2 addition on the given inputs.
pub fn syscall_bn254_fp2_addmod(p: *mut u64, q: *const u64);
/// Executes a BN254 Fp2 subtraction on the given inputs.
pub fn syscall_bn254_fp2_submod(p: *mut u64, q: *const u64);
/// Executes a BN254 Fp2 multiplication on the given inputs.
pub fn syscall_bn254_fp2_mulmod(p: *mut u64, q: *const u64);
/*
/// Executes a Secp256k1 field addition on the given inputs.
pub fn syscall_secp256k1_fp_addmod(p: *mut u32, q: *const u32);
/// Executes a Secp256k1 field subtraction on the given inputs.
pub fn syscall_secp256k1_fp_submod(p: *mut u32, q: *const u32);
/// Executes a Secp256k1 field multiplication on the given inputs.
pub fn syscall_secp256k1_fp_mulmod(p: *mut u32, q: *const u32);
*/
/// Executes an poseidon2 permute on the given inputs.
pub fn syscall_poseidon2_permute(x: *const [u32; 16], y: *mut [u32; 16]);
}