change type of transaction merkle root and challenge

This commit is contained in:
Mark Spanbroek 2024-12-05 08:24:30 +01:00
parent f5318832e4
commit 9917e5b229
5 changed files with 20 additions and 20 deletions

View File

@ -36,8 +36,8 @@ func toBytes*(transaction: Transaction): seq[byte] =
requestId: @(array[32, byte](transaction.requestId)),
slotIndex: transaction.slotIndex,
period: transaction.period.uint64,
merkleRoot: @(transaction.merkleRoot.toBytesBE()), # TODO: should this not be array[32, byte]?
challenge: @(transaction.challenge.toBytesBE()) # TODO ^^^
merkleRoot: @(transaction.merkleRoot),
challenge: @(transaction.challenge)
)
if transaction.kind == TransactionKind.storageProof:
message.proof = Groth16ProofMessage(

View File

@ -17,8 +17,8 @@ type
requestId: StorageRequestId
slotIndex: uint32
period: Period
merkleRoot: UInt256
challenge: UInt256
merkleRoot: array[32, byte]
challenge: array[32, byte]
case kind: TransactionKind
of storageProof:
proof: Groth16Proof
@ -30,8 +30,8 @@ func storageProof*(
requestId: StorageRequestId,
slotIndex: uint32,
period: Period,
merkleRoot: UInt256,
challenge: UInt256,
merkleRoot: array[32, byte],
challenge: array[32, byte],
proof: Groth16Proof
): Transaction =
Transaction(
@ -49,8 +49,8 @@ func missingProof*(
requestId: StorageRequestId,
slotIndex: uint32,
period: Period,
merkleRoot: UInt256,
challenge: UInt256,
merkleRoot: array[32, byte],
challenge: array[32, byte],
): Transaction =
Transaction(
kind: TransactionKind.missingProof,
@ -76,10 +76,10 @@ func slotIndex*(transaction: Transaction): uint32 =
func period*(transaction: Transaction): Period =
transaction.period
func merkleRoot*(transaction: Transaction): UInt256 =
func merkleRoot*(transaction: Transaction): array[32, byte] =
transaction.merkleRoot
func challenge*(transaction: Transaction): UInt256 =
func challenge*(transaction: Transaction): array[32, byte] =
transaction.challenge
func proof*(transaction: Transaction): Groth16Proof =

View File

@ -47,8 +47,8 @@ proc example*(_: type Transaction): Transaction =
let requestId = StorageRequestId.example
let slotIndex = uint32.example
let period = Period.example
let merkleRoot = UInt256.example
let challenge = UInt256.example
let merkleRoot = array[32, byte].example
let challenge = array[32, byte].example
case kind
of TransactionKind.missingProof:
Transaction.missingProof(

View File

@ -17,8 +17,8 @@ suite "Transaction serialization":
check protobuf.requestId == array[32, byte](transaction.requestId)
check protobuf.slotIndex == transaction.slotIndex
check protobuf.period == transaction.period.uint64
check protobuf.merkleRoot == transaction.merkleRoot.toBytesBE()
check protobuf.challenge == transaction.challenge.toBytesBE()
check protobuf.merkleRoot == array[32, byte](transaction.merkleRoot)
check protobuf.challenge == array[32, byte](transaction.challenge)
test "serializes a storage proof with protobuf":
let proof = Groth16Proof.example
@ -26,8 +26,8 @@ suite "Transaction serialization":
StorageRequestId.example,
uint32.example,
Period.example,
UInt256.example,
UInt256.example,
array[32, byte].example,
array[32, byte].example,
proof
)
let serialized = transaction.toBytes()

View File

@ -9,8 +9,8 @@ suite "Transaction":
let requestId = StorageRequestId.example
let slotIndex = uint32.example
let period = Period.example
let merkleRoot = UInt256.example
let challenge = UInt256.example
let merkleRoot = array[32, byte].example
let challenge = array[32, byte].example
let proof = Groth16Proof.example
let transaction = Transaction.storageProof(
requestId, slotIndex, period, merkleRoot, challenge, proof
@ -26,8 +26,8 @@ suite "Transaction":
let requestId = StorageRequestId.example
let slotIndex = uint32.example
let period = Period.example
let merkleRoot = UInt256.example
let challenge = UInt256.example
let merkleRoot = array[32, byte].example
let challenge = array[32, byte].example
let transaction = Transaction.missingProof(
requestId, slotIndex, period, merkleRoot, challenge
)