Skip to content

Commit 30a1566

Browse files
committed
Update codebase to correspond to o1Labs/proof-systems
1 parent 407abfd commit 30a1566

File tree

3 files changed

+11
-14
lines changed

3 files changed

+11
-14
lines changed

mina-p2p-messages/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ license = "Apache-2.0"
77
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
88

99
[dependencies]
10+
ark-serialize = { workspace = true }
1011
base64 = "0.22"
1112
binprot = { git = "https://github.com/openmina/binprot-rs", rev = "400b52c" }
1213
binprot_derive = { git = "https://github.com/openmina/binprot-rs", rev = "400b52c" }

mina-p2p-messages/src/bigint.rs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use ark_ff::BigInteger256;
2+
use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};
23
use malloc_size_of::MallocSizeOf;
34
use rsexp::{OfSexp, SexpOf};
45
use serde::{Deserialize, Serialize};
@@ -63,16 +64,14 @@ impl BigInt {
6364
}
6465

6566
pub fn to_bytes(&self) -> [u8; 32] {
66-
use ark_ff::ToBytes;
67-
let mut bytes = std::io::Cursor::new([0u8; 32]);
68-
self.0 .0.write(&mut bytes).unwrap(); // Never fail, there is 32 bytes
69-
bytes.into_inner()
67+
let mut bytes = Vec::with_capacity(32);
68+
self.0.serialize_uncompressed(&mut bytes).unwrap(); // Never fail, there is 32 bytes
69+
bytes.try_into().unwrap()
7070
}
7171

7272
pub fn from_bytes(bytes: [u8; 32]) -> Self {
73-
use ark_ff::FromBytes;
74-
let value = FromBytes::read(&bytes[..]).expect("Don't fail");
75-
Self(BigInteger256::new(value)) // Never fail, we read from 32 bytes
73+
let value = BigInteger256::deserialize_uncompressed(&bytes[..]).expect("Don't fail");
74+
Self(value) // Never fail, we read from 32 bytes
7675
}
7776

7877
pub fn from_decimal(s: &str) -> Result<Self, InvalidDecimalNumber> {
@@ -211,17 +210,15 @@ impl binprot::BinProtRead for BigInt {
211210
where
212211
Self: Sized,
213212
{
214-
use ark_ff::FromBytes;
215-
let value = FromBytes::read(r)?;
216-
Ok(Self(BigInteger256::new(value)))
213+
let mut bytes = [0u8; 32];
214+
r.read_exact(&mut bytes)?;
215+
Ok(Self::from_bytes(bytes))
217216
}
218217
}
219218

220219
impl binprot::BinProtWrite for BigInt {
221220
fn binprot_write<W: std::io::Write>(&self, w: &mut W) -> std::io::Result<()> {
222-
use ark_ff::ToBytes;
223-
let Self(biginteger) = self;
224-
biginteger.0.write(w)
221+
w.write_all(&self.to_bytes())
225222
}
226223
}
227224

vrf/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use ark_ec::{AffineRepr, CurveGroup};
22
use ark_ff::PrimeField;
3-
use core::ops::Mul;
43
use ledger::AccountIndex;
54
use message::VrfMessage;
65
use mina_node_account::AccountPublicKey;

0 commit comments

Comments
 (0)