diff --git a/blscurve/bls_batch_verifier.nim b/blscurve/bls_batch_verifier.nim index 95dabcb..d44c6ed 100644 --- a/blscurve/bls_batch_verifier.nim +++ b/blscurve/bls_batch_verifier.nim @@ -54,31 +54,21 @@ type # Per-batch contexts for multithreaded batch verification batchContexts: seq[ContextMultiAggregateVerify[DST]] - when compileOption("threads"): - flows: seq[Flowvar[bool]] # Serial Batch Verifier # ---------------------------------------------------------------------- func init*(T: type BatchedBLSVerifierCache): T = ## Initialise the cache for single-threaded usage - when compileOption("threads"): - BatchedBLSVerifierCache( - batchContexts: newSeq[ContextMultiAggregateVerify[DST]](1), - flows: @[] - ) - else: - BatchedBLSVerifierCache( - batchContexts: newSeq[ContextMultiAggregateVerify[DST]](1), - ) - + BatchedBLSVerifierCache( + batchContexts: newSeq[ContextMultiAggregateVerify[DST]](1), + ) when compileOption("threads"): func init*(T: type BatchedBLSVerifierCache, tp: Taskpool): T = ## Initialise the cache for multi-threaded usage BatchedBLSVerifierCache( batchContexts: newSeq[ContextMultiAggregateVerify[DST]](tp.numThreads), - flows: newSeq[Flowvar[bool]](tp.numThreads) ) func batchVerifySerial*( diff --git a/blscurve/eth2_keygen/hkdf.nim b/blscurve/eth2_keygen/hkdf.nim index 2c476c0..fc6cda5 100644 --- a/blscurve/eth2_keygen/hkdf.nim +++ b/blscurve/eth2_keygen/hkdf.nim @@ -82,8 +82,8 @@ import nimcrypto/hmac -func hkdfExtract*[T;S,I: char|byte](ctx: var HMAC[T], - prk: var MDigest[T.bits], +func hkdfExtract*[T;M;S,I: char|byte](ctx: var HMAC[T], + prk: var M, # MDigest[T.bits] salt: openArray[S], ikm: openArray[I], append: static openArray[I] @@ -108,6 +108,9 @@ func hkdfExtract*[T;S,I: char|byte](ctx: var HMAC[T], ## - ctx: a HMAC["cryptographic-hash"] context, for example HMAC[sha256]. mixin init, update, finish + + # TODO https://github.com/nim-lang/Nim/issues/22494 + static: doAssert M.bits == T.bits ctx.init(salt) ctx.update(ikm) when append.len > 0: @@ -116,8 +119,8 @@ func hkdfExtract*[T;S,I: char|byte](ctx: var HMAC[T], # ctx.clear() - TODO: very expensive -func hkdfExpand*[T;I,A: char|byte](ctx: var HMAC[T], - prk: MDigest[T.bits], +func hkdfExpand*[T;M;I,A: char|byte](ctx: var HMAC[T], + prk: M, # MDigest[T.bits] info: openArray[I], append: static openArray[A], output: var openArray[byte] @@ -141,6 +144,8 @@ func hkdfExpand*[T;I,A: char|byte](ctx: var HMAC[T], ## - ctx: a HMAC["cryptographic-hash"] context, for example HMAC[sha256]. mixin init, update, finish + # TODO https://github.com/nim-lang/Nim/issues/22494 + static: doAssert M.bits == T.bits const HashLen = T.bits div 8 static: doAssert T.bits >= 0 diff --git a/blscurve/miracl/common.nim b/blscurve/miracl/common.nim index b15f349..dae3fea 100644 --- a/blscurve/miracl/common.nim +++ b/blscurve/miracl/common.nim @@ -535,7 +535,7 @@ func fromBytes*(res: var BIG_384, a: openArray[byte]): bool = let length = if len(a) > MODBYTES_384: MODBYTES_384 else: len(a) for i in 0..