mirror of
https://github.com/logos-blockchain/lssa-zkvm-testing.git
synced 2026-01-04 22:33:07 +00:00
updates
Realistic tests for single_hash and merkle_tree
This commit is contained in:
parent
7165d4d221
commit
7c96584d2c
@ -7,34 +7,39 @@ fn main() {
|
||||
// read the input
|
||||
let input: u32 = env::read();
|
||||
|
||||
let comp1 = 1u8;
|
||||
let comp2 = 2u8;
|
||||
let comp3 = 3u8;
|
||||
let comp4 = 4u8;
|
||||
let comp5 = 5u8;
|
||||
let comp6 = 6u8;
|
||||
let comp7 = 7u8;
|
||||
let comp8 = 0u8;
|
||||
|
||||
let h1 = Impl::hash_bytes(&[comp1]);
|
||||
let h2 = Impl::hash_bytes(&[comp2]);
|
||||
let h3 = Impl::hash_bytes(&[comp3]);
|
||||
let h4 = Impl::hash_bytes(&[comp4]);
|
||||
let h5 = Impl::hash_bytes(&[comp5]);
|
||||
let h6 = Impl::hash_bytes(&[comp6]);
|
||||
let h7 = Impl::hash_bytes(&[comp7]);
|
||||
let h8 = Impl::hash_bytes(&[comp8]);
|
||||
let version = b"NSSA_v01";
|
||||
//owner_x is the x coordinate of the GENERATOR in k256.
|
||||
let owner_x = [0x79, 0xbe, 0x66, 0x7e, 0xf9, 0xdc, 0xbb, 0xac, 0x55, 0xa0, 0x62, 0x95, 0xce, 0x87,
|
||||
0x0b, 0x07, 0x02, 0x9b, 0xfc, 0xdb, 0x2d, 0xce, 0x28, 0xd9, 0x59, 0xf2, 0x81, 0x5b,
|
||||
0x16, 0xf8, 0x17, 0x98,];
|
||||
let amount = 3u64;
|
||||
let storage = b"test_string_of_32_chars_storage_";
|
||||
let nonce = 24u64;
|
||||
let privacy = 1u8;
|
||||
let const1 = 7u64;
|
||||
let const2 = 124u64;
|
||||
|
||||
let h1 = Impl::hash_bytes(version);
|
||||
let h2 = Impl::hash_bytes(&owner_x);
|
||||
let h3 = Impl::hash_bytes(&[amount.try_into().unwrap()]);
|
||||
let h4 = Impl::hash_bytes(storage);
|
||||
let h5 = Impl::hash_bytes(&[nonce.try_into().unwrap()]);
|
||||
let h6 = Impl::hash_bytes(&[privacy]);
|
||||
let h7 = Impl::hash_bytes(&[const1.try_into().unwrap()]);
|
||||
let h8 = Impl::hash_bytes(&[const2.try_into().unwrap()]);
|
||||
|
||||
let h11 = Impl::hash_pair(&h1, &h2);
|
||||
let h12 = Impl::hash_pair(&h3, &h4);
|
||||
let h13 = Impl::hash_pair(&h5, &h6);
|
||||
let h14 = Impl::hash_pair(&h7, &h8);
|
||||
let h14 = Impl::hash_pair(&h7, &h7);
|
||||
|
||||
let h21 = Impl::hash_pair(&h11, &h12);
|
||||
let h22 = Impl::hash_pair(&h13, &h14);
|
||||
|
||||
let _root = Impl::hash_pair(&h21, &h22);
|
||||
|
||||
|
||||
// write public output to the journal
|
||||
env::commit(&input);
|
||||
}
|
||||
@ -2,16 +2,17 @@ use risc0_zkvm::{
|
||||
guest::env,
|
||||
sha::{Impl, Sha256},
|
||||
};
|
||||
use zerocopy::IntoBytes;
|
||||
use k256::elliptic_curve::group::GroupEncoding;
|
||||
|
||||
|
||||
fn main() {
|
||||
// read the input
|
||||
let input: u32 = env::read();
|
||||
|
||||
let version = String::from("NSSA_v01");
|
||||
let owner = k256::ProjectivePoint::GENERATOR;
|
||||
//owner_x is the x coordinate of the GENERATOR in k256.
|
||||
let owner_x = [0x79, 0xbe, 0x66, 0x7e, 0xf9, 0xdc, 0xbb, 0xac, 0x55, 0xa0, 0x62, 0x95, 0xce, 0x87,
|
||||
0x0b, 0x07, 0x02, 0x9b, 0xfc, 0xdb, 0x2d, 0xce, 0x28, 0xd9, 0x59, 0xf2, 0x81, 0x5b,
|
||||
0x16, 0xf8, 0x17, 0x98,];
|
||||
//let owner = k256::ProjectivePoint::GENERATOR;
|
||||
let amount = 3u64;
|
||||
let storage = String::from("test_string_of_32_chars_storage_");
|
||||
let nonce = 24u64;
|
||||
@ -19,22 +20,20 @@ fn main() {
|
||||
let const1 = 7u64;
|
||||
let const2 = 124u64;
|
||||
|
||||
//version
|
||||
//owner
|
||||
let mut array2 = [owner.to_bytes()];
|
||||
let mut array3 = [amount.try_into().unwrap()];
|
||||
//storage
|
||||
let array4 = [ nonce.try_into().unwrap(),
|
||||
privacy,
|
||||
const1.try_into().unwrap(),
|
||||
const2.try_into().unwrap(),];
|
||||
//array2.clone_from_slice(&array3);
|
||||
array3.clone_from_slice(&array4);
|
||||
let mut bytes_to_hash: [u8; 105] = [0; 105];
|
||||
|
||||
//array1.clone_from_slice(&array3);
|
||||
//array1.clone_from_slice(array4);
|
||||
// let owner_bytes = owner.to_bytes();
|
||||
|
||||
bytes_to_hash[..8].copy_from_slice(&version.as_bytes());
|
||||
bytes_to_hash[8..40].copy_from_slice(&owner_x);
|
||||
bytes_to_hash[40..48].copy_from_slice(&amount.to_le_bytes());
|
||||
bytes_to_hash[48..80].copy_from_slice(&storage.as_bytes());
|
||||
bytes_to_hash[80..88].copy_from_slice(&nonce.to_le_bytes());
|
||||
bytes_to_hash[88..89].copy_from_slice(&privacy.to_le_bytes());
|
||||
bytes_to_hash[89..97].copy_from_slice(&const1.to_le_bytes());
|
||||
bytes_to_hash[97..].copy_from_slice(&const2.to_le_bytes());
|
||||
|
||||
let _hash = Impl::hash_bytes(&array3);
|
||||
let _hash = Impl::hash_bytes(&bytes_to_hash);
|
||||
|
||||
// write public output to the journal
|
||||
env::commit(&input);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user