-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: put abomonation under a feature
- Loading branch information
1 parent
bde73e0
commit 4aff3af
Showing
7 changed files
with
68 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,32 @@ | ||
// This should only run with the abomonation feature, see https://github.com/rust-lang/cargo/issues/4663 | ||
#[cfg(feature = "abomonation")] | ||
use abomonation::{decode, encode}; | ||
#[cfg(feature = "abomonation")] | ||
use blstrs::Scalar as Fr; | ||
#[cfg(feature = "abomonation")] | ||
use generic_array::typenum::U24; | ||
#[cfg(feature = "abomonation")] | ||
use neptune::{poseidon::PoseidonConstants, Strength}; | ||
|
||
fn main() { | ||
let mut bytes = Vec::new(); | ||
unsafe { | ||
let constants = PoseidonConstants::<Fr, U24>::new_with_strength(Strength::Standard); | ||
encode(&constants, &mut bytes).unwrap() | ||
}; | ||
println!("Encoded!"); | ||
println!("Read size: {}", bytes.len()); | ||
#[cfg(feature = "abomonation")] | ||
{ | ||
let mut bytes = Vec::new(); | ||
unsafe { | ||
let constants = PoseidonConstants::<Fr, U24>::new_with_strength(Strength::Standard); | ||
encode(&constants, &mut bytes).unwrap() | ||
}; | ||
println!("Encoded!"); | ||
println!("Read size: {}", bytes.len()); | ||
|
||
if let Some((result, remaining)) = unsafe { decode::<PoseidonConstants<Fr, U24>>(&mut bytes) } { | ||
let constants = PoseidonConstants::<Fr, U24>::new_with_strength(Strength::Standard); | ||
assert!(result.clone() == constants, "not equal!"); | ||
assert!(remaining.is_empty()); | ||
} else { | ||
println!("Something terrible happened"); | ||
if let Some((result, remaining)) = | ||
unsafe { decode::<PoseidonConstants<Fr, U24>>(&mut bytes) } | ||
{ | ||
let constants = PoseidonConstants::<Fr, U24>::new_with_strength(Strength::Standard); | ||
assert!(result.clone() == constants, "not equal!"); | ||
assert!(remaining.is_empty()); | ||
} else { | ||
println!("Something terrible happened"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters