mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-01-07 16:33:08 +00:00
chore: use BE
This commit is contained in:
parent
3aa35cec71
commit
312169999e
@ -837,26 +837,19 @@ suite "Waku rln relay":
|
|||||||
msgValidate2 == MessageValidationResult.Valid
|
msgValidate2 == MessageValidationResult.Valid
|
||||||
|
|
||||||
test "toIDCommitment and toUInt256":
|
test "toIDCommitment and toUInt256":
|
||||||
# create an instance of rln
|
|
||||||
let rlnInstance = createRLNInstanceWrapper()
|
|
||||||
require:
|
|
||||||
rlnInstance.isOk()
|
|
||||||
|
|
||||||
let rln = rlnInstance.get()
|
|
||||||
|
|
||||||
# create an idendity credential
|
|
||||||
let idCredentialRes = rln.membershipKeyGen()
|
let idCredentialRes = rln.membershipKeyGen()
|
||||||
require:
|
require:
|
||||||
idCredentialRes.isOk()
|
idCredentialRes.isOk()
|
||||||
|
|
||||||
let idCredential = idCredentialRes.get()
|
let idCredential = idCredentialRes.get()
|
||||||
|
|
||||||
# convert the idCommitment to UInt256
|
# convert the idCommitment to UInt256 (now using big-endian)
|
||||||
let idCUInt = idCredential.idCommitment.toUInt256()
|
let idCUInt = idCredential.idCommitment.toUInt256()
|
||||||
# convert the UInt256 back to ICommitment
|
# convert the UInt256 back to ICommitment
|
||||||
let idCommitment = toIDCommitment(idCUInt)
|
let idCommitment = toIDCommitment(idCUInt)
|
||||||
|
|
||||||
# check that the conversion has not distorted the original value
|
# check that the conversion has not distorted the original value
|
||||||
|
# This test now expects big-endian round-trip
|
||||||
check:
|
check:
|
||||||
idCredential.idCommitment == idCommitment
|
idCredential.idCommitment == idCommitment
|
||||||
|
|
||||||
|
|||||||
@ -26,7 +26,7 @@ type IdentityCredential* = object
|
|||||||
idCommitment*: IDCommitment
|
idCommitment*: IDCommitment
|
||||||
|
|
||||||
proc toUInt256*(idCommitment: IDCommitment): UInt256 =
|
proc toUInt256*(idCommitment: IDCommitment): UInt256 =
|
||||||
let pk = UInt256.fromBytesLE(idCommitment)
|
let pk = UInt256.fromBytesBE(idCommitment)
|
||||||
return pk
|
return pk
|
||||||
|
|
||||||
proc toIDCommitment*(idCommitmentUint: UInt256): IDCommitment =
|
proc toIDCommitment*(idCommitmentUint: UInt256): IDCommitment =
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user