Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use "poseidon_hash_2" for merkle trees instead of poseidon_hash_many #312

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
scarb 2.8.4
scarb 2.9.1
2 changes: 1 addition & 1 deletion packages/client/tests/data/utreexo_1.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
"roots": [
{
"variant_id": 0,
"value": 2915651996892698521196383484133475266682410400159810761618404984775762993564
"value": 1279356337170024898679470415212483832295983869749962019370698943024896904815
}
],
"num_leaves": 2
Expand Down
26 changes: 13 additions & 13 deletions packages/client/tests/data/utreexo_169.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,15 @@
"roots": [
{
"variant_id": 0,
"value": 1502558161404968896970257403264055788192189695540729001360864566276543485500
"value": 561274160955419959489959425275064806582463921086932538267303774042399663538
},
{
"variant_id": 0,
"value": 1377893971144855926456275647843230957136416614121223440964512004900657355746
"value": 2321106996335186209530102874448719925598418554740914877511261391512409785647
},
{
"variant_id": 0,
"value": 1545231468516220002373273797559461807914970524111940849750328803582855936171
"value": 1964072998355903590755820045880478489641806021519598304957686152200188695923
},
{
"variant_id": 0,
Expand All @@ -148,12 +148,12 @@
"proof": {
"proof": [
1341831566043387106325844845909158799402866001662974927108069625603583971480,
1443675700228503369543683218943466499245617322985505154945738943716743694265,
519646392377825945466547611274092870030802470736981675895864465165188803020,
1080650929466224224603091215856096240942830750577279058777853241919006292201,
3429608730564493038725327726731886582242605618763607208860625722555112702870,
1464346753344216951108436013919475968846135803696833681088250234646995926893,
2059532798546650597701371553400476891060690283065963625811202716166665983015
741440833574406111691149629246387179992846413644921535247530688784871842074,
3008454340260728261604617202105700406642368686787541541072425957257158190395,
688668003784340726428824892475273286272091664800857247826208869301493469793,
3042843992639234445908544345231206343064719350368672746473799617663186211857,
3417306654905318829953224363807050055977017172685290016671747402681790962566,
1669339025434925584008510712330543098614790501472801654588532043481144625751
],
"targets": [
8
Expand All @@ -163,19 +163,19 @@
"roots": [
{
"variant_id": 0,
"value": 472495115707702931286975202981613081341496930913817199425502977245962405497
"value": 378721347931125330846388909871493233963774829132943825228363846772391361948
},
{
"variant_id": 0,
"value": 1377893971144855926456275647843230957136416614121223440964512004900657355746
"value": 2321106996335186209530102874448719925598418554740914877511261391512409785647
},
{
"variant_id": 0,
"value": 1545231468516220002373273797559461807914970524111940849750328803582855936171
"value": 1964072998355903590755820045880478489641806021519598304957686152200188695923
},
{
"variant_id": 0,
"value": 940126151801873300266416875114055738009783862579557360123104711005733824770
"value": 2271380128300701625807420920897171315599836800484820324430043541967263028071
}
],
"num_leaves": 172
Expand Down
22 changes: 11 additions & 11 deletions packages/client/tests/data/utreexo_182.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,23 +128,23 @@
"roots": [
{
"variant_id": 0,
"value": 472495115707702931286975202981613081341496930913817199425502977245962405497
"value": 378721347931125330846388909871493233963774829132943825228363846772391361948
},
{
"variant_id": 0,
"value": 1377893971144855926456275647843230957136416614121223440964512004900657355746
"value": 2321106996335186209530102874448719925598418554740914877511261391512409785647
},
{
"variant_id": 0,
"value": 3379475774617422517749239484786779535800164983837536926832995269432589051493
"value": 1311085345304770468188661818644354993791705092641622017733031578640830315194
},
{
"variant_id": 0,
"value": 2960972179536349754495570588856684293379166070401208198804481828943354090177
"value": 558456643494990312815826591834250277629365012897391712724354262056923111667
},
{
"variant_id": 0,
"value": 1027525398361326601103535357192346699264220866701033959615605604739328879107
"value": 2342589903993092177260043418175760800986047939041119265186586591322947261529
}
],
"num_leaves": 188
Expand All @@ -162,27 +162,27 @@
"roots": [
{
"variant_id": 0,
"value": 472495115707702931286975202981613081341496930913817199425502977245962405497
"value": 378721347931125330846388909871493233963774829132943825228363846772391361948
},
{
"variant_id": 0,
"value": 1377893971144855926456275647843230957136416614121223440964512004900657355746
"value": 2321106996335186209530102874448719925598418554740914877511261391512409785647
},
{
"variant_id": 0,
"value": 3379475774617422517749239484786779535800164983837536926832995269432589051493
"value": 1311085345304770468188661818644354993791705092641622017733031578640830315194
},
{
"variant_id": 0,
"value": 2960972179536349754495570588856684293379166070401208198804481828943354090177
"value": 558456643494990312815826591834250277629365012897391712724354262056923111667
},
{
"variant_id": 0,
"value": 1393936218426697313222000203973633691677533429852178919818058911865240713624
"value": 1474833081294688969916558816142164051328784316501622250558941821006253727270
},
{
"variant_id": 0,
"value": 388190300499697056611762555012906818486802305728968255357693461417536026290
"value": 1840886845465363843062084265974897673231882991239538441759344673843123519428
},
{
"variant_id": 0,
Expand Down
7 changes: 4 additions & 3 deletions packages/utreexo/src/lib.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ pub mod vanilla {
}
pub mod test;

use core::hash::{HashStateTrait, HashStateExTrait};
use core::poseidon::PoseidonTrait;
use core::poseidon::hades_permutation;

/// Parent hash of two Utreexo nodes.
#[inline]
fn parent_hash(left: felt252, right: felt252) -> felt252 {
return PoseidonTrait::new().update_with(left).update_with(right).finalize();
let (res, _, _) = hades_permutation(left, right, 2);
return res;
}
Loading