@@ -58,7 +58,6 @@ import 'package:polygonid_flutter_sdk/iden3comm/domain/exceptions/iden3comm_exce
5858import 'package:polygonid_flutter_sdk/iden3comm/domain/exceptions/jwz_exceptions.dart' ;
5959import 'package:polygonid_flutter_sdk/iden3comm/domain/use_cases/generate_iden3comm_proof_use_case.dart' ;
6060import 'package:polygonid_flutter_sdk/iden3comm/domain/use_cases/get_iden3message_use_case.dart' ;
61- import 'package:polygonid_flutter_sdk/identity/data/data_sources/lib_babyjubjub_data_source.dart' ;
6261import 'package:polygonid_flutter_sdk/identity/data/data_sources/lib_pidcore_identity_data_source.dart' ;
6362import 'package:polygonid_flutter_sdk/identity/data/data_sources/wallet_data_source.dart' ;
6463import 'package:polygonid_flutter_sdk/identity/data/dtos/circuit_type.dart' ;
@@ -88,6 +87,8 @@ import 'package:polygonid_flutter_sdk/proof/gist_proof_cache.dart';
8887import 'package:polygonid_flutter_sdk/proof/infrastructure/proof_generation_stream_manager.dart' ;
8988import 'package:polygonid_flutter_sdk/proof/libs/polygonidcore/pidcore_proof.dart' ;
9089import 'package:polygonid_flutter_sdk/sdk/di/injector.dart' ;
90+ import 'package:poseidon/constants/p1.dart' ;
91+ import 'package:poseidon/poseidon.dart' ;
9192import 'package:sembast/sembast.dart' ;
9293import 'package:uuid/uuid.dart' ;
9394import 'package:web3dart/crypto.dart' ;
@@ -1027,11 +1028,9 @@ class Authenticate {
10271028 // Endianness
10281029 BigInt endian = Uint8ArrayUtils .leBuff2int (sha);
10291030
1030- String qNormalized = endian.qNormalize (). toString ();
1031+ BigInt qNormalized = endian.qNormalize ();
10311032
1032- var libBabyJubJub = getItSdk <LibBabyJubJubDataSource >();
1033-
1034- String authChallenge = await libBabyJubJub.hashPoseidon (qNormalized);
1033+ String authChallenge = poseidon1 ([qNormalized]).toString ();
10351034
10361035 String signature = await signMessage (
10371036 privateKey: privateKeyBytes,
@@ -1140,28 +1139,30 @@ class Authenticate {
11401139 publicKey: publicKey,
11411140 );
11421141 authClaim = List .from (jsonDecode (issuedAuthClaim));
1143- var libBabyJubJub = getItSdk <LibBabyJubJubDataSource >();
1144- String hashIndex = await libBabyJubJub.hashPoseidon4 (
1145- authClaim[0 ],
1146- authClaim[1 ],
1147- authClaim[2 ],
1148- authClaim[3 ],
1149- );
1150- String hashValue = await libBabyJubJub.hashPoseidon4 (
1151- authClaim[4 ],
1152- authClaim[5 ],
1153- authClaim[6 ],
1154- authClaim[7 ],
1155- );
1156- String hashClaimNode = await libBabyJubJub.hashPoseidon3 (
1157- hashIndex, hashValue, BigInt .one.toString ());
1142+ BigInt hashIndex = poseidon4 ([
1143+ BigInt .parse (authClaim[0 ]),
1144+ BigInt .parse (authClaim[1 ]),
1145+ BigInt .parse (authClaim[2 ]),
1146+ BigInt .parse (authClaim[3 ]),
1147+ ]);
1148+ BigInt hashValue = poseidon4 ([
1149+ BigInt .parse (authClaim[4 ]),
1150+ BigInt .parse (authClaim[5 ]),
1151+ BigInt .parse (authClaim[6 ]),
1152+ BigInt .parse (authClaim[7 ]),
1153+ ]);
1154+ BigInt hashClaimNode = poseidon3 ([
1155+ hashIndex,
1156+ hashValue,
1157+ BigInt .one,
1158+ ]);
11581159 NodeEntity authClaimNode = NodeEntity (
11591160 children: [
1160- HashEntity .fromBigInt (BigInt . parse ( hashIndex) ),
1161- HashEntity .fromBigInt (BigInt . parse ( hashValue) ),
1161+ HashEntity .fromBigInt (hashIndex),
1162+ HashEntity .fromBigInt (hashValue),
11621163 HashEntity .fromBigInt (BigInt .one),
11631164 ],
1164- hash: HashEntity .fromBigInt (BigInt . parse ( hashClaimNode) ),
1165+ hash: HashEntity .fromBigInt (hashClaimNode),
11651166 type: NodeType .leaf,
11661167 );
11671168
0 commit comments