Skip to content

Commit e3cf969

Browse files
committed
Switch to Ceno field element and transcript
1 parent f1d7328 commit e3cf969

File tree

18 files changed

+1701
-2095
lines changed

18 files changed

+1701
-2095
lines changed

circ_blocks/examples/zxc.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ use std::path::PathBuf;
3131
use libspartan::{
3232
instance::Instance, Assignment, InputsAssignment, MemsAssignment, VarsAssignment, SNARK,
3333
};
34-
use merlin::Transcript;
3534
use serde::{Deserialize, Serialize};
3635
use std::time::*;
3736

spartan_parallel/examples/interface.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::{fs::File, io::BufReader};
77

88
use libspartan::scalar::{ScalarExt2, SpartanExtensionField};
99
use libspartan::{instance::Instance, InputsAssignment, MemsAssignment, VarsAssignment, SNARK};
10-
use merlin::Transcript;
10+
use transcript::BasicTranscript as Transcript;
1111
use serde::{Deserialize, Serialize};
1212
use std::time::*;
1313

spartan_parallel/src/bytes.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
use ff_ext::ExtensionField;
2+
use subtle::{Choice, CtOption};
3+
4+
/// Attempts to convert a little-endian byte representation of
5+
/// a field element into an `ExtensionField`, failing if the input is not canonical.
6+
pub fn from_bytes<E: ExtensionField>(bytes: &[u8; 32]) -> CtOption<E> {
7+
let mut padded = [0u8; 64];
8+
padded[..32].copy_from_slice(bytes);
9+
10+
CtOption::new(
11+
E::from_uniform_bytes(&padded),
12+
Choice::from(1u8),
13+
)
14+
}
15+
16+
/// Converts an element of `ExtensionField` into a byte representation in
17+
/// little-endian byte order.
18+
pub fn to_bytes<E: ExtensionField>(num: E) -> [u8; 32] {
19+
let mut res = [0; 32];
20+
let els = num.to_canonical_u64_vec();
21+
res[..8].copy_from_slice(&els[0].to_le_bytes());
22+
res[8..16].copy_from_slice(&els[1].to_le_bytes());
23+
res
24+
}
25+
26+
/// Converts a 512-bit little endian integer into
27+
/// an `ExtensionField` element by reducing by the modulus.
28+
pub fn from_bytes_wide<E: ExtensionField>(bytes: &[u8; 64]) -> E {
29+
E::from_uniform_bytes(bytes).into()
30+
}

0 commit comments

Comments
 (0)