ppad measure

Constant-Time Analysis: ppad-secp256k1

target
ppad-secp256k1 0.5.9 (b3494fa)
git.ppad.tech/secp256k1
toolchain
GHC 9.10.3 (NCG)
vestigia
16 secrets per execution (aarch64 on a72; x86_64 on zen3)
censor
aarch64-linux (instructions), x86_64-linux (instructions)
generated
2026-11-03 (synthesis)
✓ no leak found in all 9 executions
vestigia
no secret-dependent branch or memory access found, in 9 traced executions (aarch64, x86_64)
censor
18 of 18 tests passed (aarch64-linux, x86_64-linux)

executions

execution verdict aarch64 x86_64
vestigia censor vestigia censor
Crypto.Curve.Secp256k1.mul
Multiplies a fixed public point by the secret scalar
✓ no leak found ✓ ✓ ✓ ✓
Crypto.Curve.Secp256k1.mul_wnaf
Multiplies the generator by the secret scalar, through a precomputed table
✓ no leak found ✓ ✓ ✓ ✓
Crypto.Curve.Secp256k1.derive_pub
Derives the secret key's public key
✓ no leak found ✓ ✓ ✓ ✓
Crypto.Curve.Secp256k1.derive_pub'
Derives the secret key's public key, through a precomputed table
✓ no leak found ✓ ✓ ✓ ✓
Crypto.Curve.Secp256k1.ecdh
Derives the shared secret of the secret key and a fixed public point
✓ no leak found ✓ ✓ ✓ ✓
Crypto.Curve.Secp256k1.sign_schnorr
Signs a fixed message with the secret key (BIP0340)
✓ no leak found ✓ ✓ ✓ ✓
Crypto.Curve.Secp256k1.sign_schnorr'
Signs a fixed message with the secret key (BIP0340), through a precomputed table
✓ no leak found ✓ ✓ ✓ ✓
Crypto.Curve.Secp256k1.sign_ecdsa
Signs a fixed message with the secret key (RFC6979, low s)
✓ no leak found ✓ ✓ ✓ ✓
Crypto.Curve.Secp256k1.sign_ecdsa'
Signs a fixed message with the secret key (RFC6979, low s), through a precomputed table
✓ no leak found ✓ ✓ ✓ ✓

✓ no leak found✗ leak? inconclusive· not run

by execution

Crypto.Curve.Secp256k1.mul

✓ no leak of scalar found
Multiplies a fixed public point by the secret scalar
contract vestigia censor
aarch64
aarch64-linux
arm-dit
✓ 1 invariant ✓ instructions
x86_64
x86_64-linux
intel-doitm
✓ 1 invariant ✓ instructions
vestigiatrace
inputs
scalar pseudorandom in [1, n), n the secp256k1 group order
point fixed, the generator times a fixed public scalar
no branch or memory address varied with the secret in the code under audit.
✓ invariant · 2 lines the secret reaches, where no run varied
functioninstructionvaries atsource
Secp256k1.$wmuljne 45e82 <+0x392>branchSecp256k1.hs:615
in Crypto.Curve.Secp256k1.$wmul · /build/z2xkjgrlfk18haq5icbwm6vd8419a03s-source/lib/Crypto/Curve/Secp256k1.hs:615
45d7c: or %rax,%r14
45d7f: neg %r14
45d82: and %r11,%r14
45d85: cmp $0xffffffffffffffff,%r14
45d89: jne 45e82 <+0x392> branch (taint)
observed by taint: branch, 16× on the secret
Secp256k1.$wmul z2xkjgrlfk18haq5icbwm6vd8419a03s-source/lib/Crypto/Curve/Secp256k1.hs:615
  603      loop !r !d !m
  604        | zero# m = r
  605        | otherwise =
  606            let !nd = double# d
  607                !(# nm, lsb_set #) = W.shr1_c# m
  608                !nr = if CT.decide lsb_set then add_proj# r d else r
  609            in  loop nr nd nm
  610  {-# INLINE mul_vartime# #-}
  611  
  612  ge# :: Limb4 -> CT.Choice
  613  ge# n =
  614    let !(Wider q) = _CURVE_Q
  615    in  CT.and (W.gt# n Z) (W.lt# n q)
  616  {-# INLINE ge# #-}
  617  
  618  mul_wnaf# :: ByteArray -> Int -> Limb4 -> (# () | Proj #)
  619  mul_wnaf# ctxArray ctxW ls
  620      | CT.decide (CT.not (ge# ls)) = (# () | #)
  621      | otherwise =
  622          let !(P zx zy zz) = _CURVE_ZERO
  623          in  (# | loop 0 (# zx, zy, zz #) ls #)
  624    where
  625      !one                  = (# Limb 1##, Limb 0##, Limb 0##, Limb 0## #)
  626      !wins                 = fi (256 `quot` ctxW + 1)
  627      !size@(GHC.Word.W# s) = 1 .<<. (ctxW - 1)
45d8f: lea 0x1a2(%rip),%rax # 45f38 <+0x448>
45d96: mov %rax,0x80(%rbp)
45d9d: xor %r9d,%r9d
45da0: mov %r8,%rax
source · Secp256k1.hs:615
  611  
  612  ge# :: Limb4 -> CT.Choice
  613  ge# n =
  614    let !(Wider q) = _CURVE_Q
  615    in  CT.and (W.gt# n Z) (W.lt# n q)
  616  {-# INLINE ge# #-}
  617  
  618  mul_wnaf# :: ByteArray -> Int -> Limb4 -> (# () | Proj #)
  619  mul_wnaf# ctxArray ctxW ls
Secp256k1.$wmulb.ne 5a8b8 <+0x558> // b.anybranch
in Crypto.Curve.Secp256k1.$wmul
5a7c0: movk x12, #0xffff, lsl #16
5a7c4: movk x12, #0xffff, lsl #32
5a7c8: movk x12, #0xffff, lsl #48
5a7cc: cmp x13, x12
5a7d0: b.ne 5a8b8 <+0x558> // b.any branch (taint)
observed by taint: branch, 16× on the secret
Secp256k1.$wmul ?
5a7d4: adrp x13, 5a000 <ppadzmsecp256k1zm0zi5zi9zminplace_CryptoziCurveziSecp256k1_precompute_info+0x7208>
5a7d8: add x13, x13, #0x3e4
5a7dc: str x13, [x20, #128]
5a7e0: mov w27, #0x0 // #0
censortiming50000 pairs · α=1.0e-6 · batch 1
test cases
Secp.mul (non-generator base) a valid scalar fixed vs random, times one fixed non-generator point
host meter result p effect (mean/pair) jitter clip scale clipped
Secp.mul (non-generator base)
aarch64-linux instructions ✓ 0.938 [-304, 101] instr 0.0% 1908 instr 11/50000
x86_64-linux instructions ✓ 0.402 [-82, 246] instr 0.0% 1540 instr 9/50000
Secp.mul (non-generator base)aarch64-linux
instructions
log(1/α) 0 0
no leak found · 50000 pairs · α=1.0e-6 · p=0.938
Secp.mul (non-generator base)x86_64-linux
instructions
log(1/α) 0 0
no leak found · 50000 pairs · α=1.0e-6 · p=0.402

Crypto.Curve.Secp256k1.mul_wnaf

✓ no leak of scalar found
Multiplies the generator by the secret scalar, through a precomputed table
contract vestigia censor
aarch64
aarch64-linux
arm-dit
✓ 1 invariant ✓ instructions
x86_64
x86_64-linux
intel-doitm
✓ 1 invariant ✓ instructions
vestigiatrace
inputs
scalar pseudorandom in [1, n), n the secp256k1 group order
generator context precomputed once, fixed
no branch or memory address varied with the secret in the code under audit.
✓ invariant · 2 lines the secret reaches, where no run varied
functioninstructionvaries atsource
Secp256k1.$wmul_wnafjne 275ce <+0xd9e>branchSecp256k1.hs:615
in Crypto.Curve.Secp256k1.$wmul_wnaf · /build/z2xkjgrlfk18haq5icbwm6vd8419a03s-source/lib/Crypto/Curve/Secp256k1.hs:615
269be: or %rax,%rsi
269c1: neg %rsi
269c4: and %r9,%rsi
269c7: cmp $0xffffffffffffffff,%rsi
269cb: jne 275ce <+0xd9e> branch (taint)
observed by taint: branch, 16× on the secret
Secp256k1.$wmul_wnaf z2xkjgrlfk18haq5icbwm6vd8419a03s-source/lib/Crypto/Curve/Secp256k1.hs:615
  603      loop !r !d !m
  604        | zero# m = r
  605        | otherwise =
  606            let !nd = double# d
  607                !(# nm, lsb_set #) = W.shr1_c# m
  608                !nr = if CT.decide lsb_set then add_proj# r d else r
  609            in  loop nr nd nm
  610  {-# INLINE mul_vartime# #-}
  611  
  612  ge# :: Limb4 -> CT.Choice
  613  ge# n =
  614    let !(Wider q) = _CURVE_Q
  615    in  CT.and (W.gt# n Z) (W.lt# n q)
  616  {-# INLINE ge# #-}
  617  
  618  mul_wnaf# :: ByteArray -> Int -> Limb4 -> (# () | Proj #)
  619  mul_wnaf# ctxArray ctxW ls
  620      | CT.decide (CT.not (ge# ls)) = (# () | #)
  621      | otherwise =
  622          let !(P zx zy zz) = _CURVE_ZERO
  623          in  (# | loop 0 (# zx, zy, zz #) ls #)
  624    where
  625      !one                  = (# Limb 1##, Limb 0##, Limb 0##, Limb 0## #)
  626      !wins                 = fi (256 `quot` ctxW + 1)
  627      !size@(GHC.Word.W# s) = 1 .<<. (ctxW - 1)
269d1: lea 0x28(%rip),%rax # 26a00 <+0x1d0>
269d8: mov %rax,0x0(%rbp)
269dc: lea 0x694cd(%rip),%rbx # 8feb0 <ppadzmsecp256k1zm0zi5zi9zminplace_CryptoziCurveziSecp256k1_zuCURVEzuZZERO4_closure>
269e3: test $0x7,%bl
source · Secp256k1.hs:615
  611  
  612  ge# :: Limb4 -> CT.Choice
  613  ge# n =
  614    let !(Wider q) = _CURVE_Q
  615    in  CT.and (W.gt# n Z) (W.lt# n q)
  616  {-# INLINE ge# #-}
  617  
  618  mul_wnaf# :: ByteArray -> Int -> Limb4 -> (# () | Proj #)
  619  mul_wnaf# ctxArray ctxW ls
Secp256k1.$wmul_wnafb.ne 2da8c <+0x1ddc> // b.anybranch
in Crypto.Curve.Secp256k1.$wmul_wnaf
3232c: movk x17, #0xffff, lsl #16
32330: movk x17, #0xffff, lsl #32
32334: movk x17, #0xffff, lsl #48
32338: cmp x18, x17
3233c: b.ne 2da8c <+0x1ddc> // b.any branch (taint)
observed by taint: branch, 16× on the secret
Secp256k1.$wmul_wnaf ?
32340: adrp x18, 32000 <+0x6350>
32344: add x18, x18, #0x2c
32348: str x18, [x20]
3234c: adrp x22, d0000 <__dso_handle>
censortiming50000 pairs · α=1.0e-6 · batch 1
test cases
Secp.mul_wnaf (precomputed generator) a valid scalar fixed vs random, times the generator through one precomputed context
host meter result p effect (mean/pair) jitter clip scale clipped
Secp.mul_wnaf (precomputed generator)
aarch64-linux instructions ✓ 0.885 [-282, 94] instr 0.0% 1770 instr 11/50000
x86_64-linux instructions ✓ 0.996 [-264, 88] instr 0.0% 1658 instr 5/50000
Secp.mul_wnaf (precomputed generator)aarch64-linux
instructions
log(1/α) 0 0
no leak found · 50000 pairs · α=1.0e-6 · p=0.885
Secp.mul_wnaf (precomputed generator)x86_64-linux
instructions
log(1/α) 0 0
no leak found · 50000 pairs · α=1.0e-6 · p=0.996

Crypto.Curve.Secp256k1.derive_pub

✓ no leak of key found
Derives the secret key's public key
contract vestigia censor
aarch64
aarch64-linux
arm-dit
✓ 1 invariant ✓ instructions
x86_64
x86_64-linux
intel-doitm
✓ 1 invariant ✓ instructions
vestigiatrace
inputs
secret key pseudorandom in [1, n), n the secp256k1 group order
no branch or memory address varied with the secret in the code under audit.
✓ invariant · 2 lines the secret reaches, where no run varied
functioninstructionvaries atsource
Secp256k1.$wmuljne 45e82 <+0x392>branchSecp256k1.hs:615
in Crypto.Curve.Secp256k1.$wmul · /build/z2xkjgrlfk18haq5icbwm6vd8419a03s-source/lib/Crypto/Curve/Secp256k1.hs:615
45d7c: or %rax,%r14
45d7f: neg %r14
45d82: and %r11,%r14
45d85: cmp $0xffffffffffffffff,%r14
45d89: jne 45e82 <+0x392> branch (taint)
observed by taint: branch, 16× on the secret
Secp256k1.$wmul z2xkjgrlfk18haq5icbwm6vd8419a03s-source/lib/Crypto/Curve/Secp256k1.hs:615
  603      loop !r !d !m
  604        | zero# m = r
  605        | otherwise =
  606            let !nd = double# d
  607                !(# nm, lsb_set #) = W.shr1_c# m
  608                !nr = if CT.decide lsb_set then add_proj# r d else r
  609            in  loop nr nd nm
  610  {-# INLINE mul_vartime# #-}
  611  
  612  ge# :: Limb4 -> CT.Choice
  613  ge# n =
  614    let !(Wider q) = _CURVE_Q
  615    in  CT.and (W.gt# n Z) (W.lt# n q)
  616  {-# INLINE ge# #-}
  617  
  618  mul_wnaf# :: ByteArray -> Int -> Limb4 -> (# () | Proj #)
  619  mul_wnaf# ctxArray ctxW ls
  620      | CT.decide (CT.not (ge# ls)) = (# () | #)
  621      | otherwise =
  622          let !(P zx zy zz) = _CURVE_ZERO
  623          in  (# | loop 0 (# zx, zy, zz #) ls #)
  624    where
  625      !one                  = (# Limb 1##, Limb 0##, Limb 0##, Limb 0## #)
  626      !wins                 = fi (256 `quot` ctxW + 1)
  627      !size@(GHC.Word.W# s) = 1 .<<. (ctxW - 1)
45d8f: lea 0x1a2(%rip),%rax # 45f38 <+0x448>
45d96: mov %rax,0x80(%rbp)
45d9d: xor %r9d,%r9d
45da0: mov %r8,%rax
source · Secp256k1.hs:615
  611  
  612  ge# :: Limb4 -> CT.Choice
  613  ge# n =
  614    let !(Wider q) = _CURVE_Q
  615    in  CT.and (W.gt# n Z) (W.lt# n q)
  616  {-# INLINE ge# #-}
  617  
  618  mul_wnaf# :: ByteArray -> Int -> Limb4 -> (# () | Proj #)
  619  mul_wnaf# ctxArray ctxW ls
Secp256k1.$wmulb.ne 5a8b8 <+0x558> // b.anybranch
in Crypto.Curve.Secp256k1.$wmul
5a7c0: movk x12, #0xffff, lsl #16
5a7c4: movk x12, #0xffff, lsl #32
5a7c8: movk x12, #0xffff, lsl #48
5a7cc: cmp x13, x12
5a7d0: b.ne 5a8b8 <+0x558> // b.any branch (taint)
observed by taint: branch, 16× on the secret
Secp256k1.$wmul ?
5a7d4: adrp x13, 5a000 <ppadzmsecp256k1zm0zi5zi9zminplace_CryptoziCurveziSecp256k1_precompute_info+0x7208>
5a7d8: add x13, x13, #0x3e4
5a7dc: str x13, [x20, #128]
5a7e0: mov w27, #0x0 // #0
censortiming50000 pairs · α=1.0e-6 · batch 1
test cases
Secp.derive_pub (generator multiplication) the secret key fixed vs random
host meter result p effect (mean/pair) jitter clip scale clipped
Secp.derive_pub (generator multiplication)
aarch64-linux instructions ✓ 0.461 [-304, 101] instr 0.0% 1908 instr 4/50000
x86_64-linux instructions ✓ 0.634 [-246, 82] instr 0.0% 1542 instr 7/50000
Secp.derive_pub (generator multiplication)aarch64-linux
instructions
log(1/α) 0 0
no leak found · 50000 pairs · α=1.0e-6 · p=0.461
Secp.derive_pub (generator multiplication)x86_64-linux
instructions
log(1/α) 0 0
no leak found · 50000 pairs · α=1.0e-6 · p=0.634

Crypto.Curve.Secp256k1.derive_pub'

✓ no leak of key found
Derives the secret key's public key, through a precomputed table
contract vestigia censor
aarch64
aarch64-linux
arm-dit
✓ 1 invariant ✓ instructions
x86_64
x86_64-linux
intel-doitm
✓ 1 invariant ✓ instructions
vestigiatrace
inputs
secret key pseudorandom in [1, n), n the secp256k1 group order
generator context precomputed once, fixed
no branch or memory address varied with the secret in the code under audit.
✓ invariant · 2 lines the secret reaches, where no run varied
functioninstructionvaries atsource
Secp256k1.$wmul_wnafjne 275ce <+0xd9e>branchSecp256k1.hs:615
in Crypto.Curve.Secp256k1.$wmul_wnaf · /build/z2xkjgrlfk18haq5icbwm6vd8419a03s-source/lib/Crypto/Curve/Secp256k1.hs:615
269be: or %rax,%rsi
269c1: neg %rsi
269c4: and %r9,%rsi
269c7: cmp $0xffffffffffffffff,%rsi
269cb: jne 275ce <+0xd9e> branch (taint)
observed by taint: branch, 16× on the secret
Secp256k1.$wmul_wnaf z2xkjgrlfk18haq5icbwm6vd8419a03s-source/lib/Crypto/Curve/Secp256k1.hs:615
  603      loop !r !d !m
  604        | zero# m = r
  605        | otherwise =
  606            let !nd = double# d
  607                !(# nm, lsb_set #) = W.shr1_c# m
  608                !nr = if CT.decide lsb_set then add_proj# r d else r
  609            in  loop nr nd nm
  610  {-# INLINE mul_vartime# #-}
  611  
  612  ge# :: Limb4 -> CT.Choice
  613  ge# n =
  614    let !(Wider q) = _CURVE_Q
  615    in  CT.and (W.gt# n Z) (W.lt# n q)
  616  {-# INLINE ge# #-}
  617  
  618  mul_wnaf# :: ByteArray -> Int -> Limb4 -> (# () | Proj #)
  619  mul_wnaf# ctxArray ctxW ls
  620      | CT.decide (CT.not (ge# ls)) = (# () | #)
  621      | otherwise =
  622          let !(P zx zy zz) = _CURVE_ZERO
  623          in  (# | loop 0 (# zx, zy, zz #) ls #)
  624    where
  625      !one                  = (# Limb 1##, Limb 0##, Limb 0##, Limb 0## #)
  626      !wins                 = fi (256 `quot` ctxW + 1)
  627      !size@(GHC.Word.W# s) = 1 .<<. (ctxW - 1)
269d1: lea 0x28(%rip),%rax # 26a00 <+0x1d0>
269d8: mov %rax,0x0(%rbp)
269dc: lea 0x694cd(%rip),%rbx # 8feb0 <ppadzmsecp256k1zm0zi5zi9zminplace_CryptoziCurveziSecp256k1_zuCURVEzuZZERO4_closure>
269e3: test $0x7,%bl
source · Secp256k1.hs:615
  611  
  612  ge# :: Limb4 -> CT.Choice
  613  ge# n =
  614    let !(Wider q) = _CURVE_Q
  615    in  CT.and (W.gt# n Z) (W.lt# n q)
  616  {-# INLINE ge# #-}
  617  
  618  mul_wnaf# :: ByteArray -> Int -> Limb4 -> (# () | Proj #)
  619  mul_wnaf# ctxArray ctxW ls
Secp256k1.$wmul_wnafb.ne 2da8c <+0x1ddc> // b.anybranch
in Crypto.Curve.Secp256k1.$wmul_wnaf
3232c: movk x17, #0xffff, lsl #16
32330: movk x17, #0xffff, lsl #32
32334: movk x17, #0xffff, lsl #48
32338: cmp x18, x17
3233c: b.ne 2da8c <+0x1ddc> // b.any branch (taint)
observed by taint: branch, 16× on the secret
Secp256k1.$wmul_wnaf ?
32340: adrp x18, 32000 <+0x6350>
32344: add x18, x18, #0x2c
32348: str x18, [x20]
3234c: adrp x22, d0000 <__dso_handle>
censortiming50000 pairs · α=1.0e-6 · batch 1
test cases
Secp.derive_pub' (precomputed generator) as derive_pub, through one precomputed context
host meter result p effect (mean/pair) jitter clip scale clipped
Secp.derive_pub' (precomputed generator)
aarch64-linux instructions ✓ 0.887 [-282, 94] instr 0.0% 1770 instr 10/50000
x86_64-linux instructions ✓ 0.142 [-17, 50] instr 0.0% 316 instr 5/50000
Secp.derive_pub' (precomputed generator)aarch64-linux
instructions
log(1/α) 0 0
no leak found · 50000 pairs · α=1.0e-6 · p=0.887
Secp.derive_pub' (precomputed generator)x86_64-linux
instructions
log(1/α) 0 0
no leak found · 50000 pairs · α=1.0e-6 · p=0.142

Crypto.Curve.Secp256k1.ecdh

✓ no leak of key found
Derives the shared secret of the secret key and a fixed public point
contract vestigia censor
aarch64
aarch64-linux
arm-dit
✓ 2 invariant ✓ instructions
x86_64
x86_64-linux
intel-doitm
✓ 2 invariant ✓ instructions
vestigiatrace
inputs
secret key pseudorandom in [1, n), n the secp256k1 group order
peer fixed, the generator times a fixed public scalar
no branch or memory address varied with the secret in the code under audit.
✓ invariant · 4 lines the secret reaches, where no run varied
functioninstructionvaries atsource
Secp256k1.$wecdhjne 7e943 <+0x440b>branchSecp256k1.hs:990
in Crypto.Curve.Secp256k1.$wecdh · /build/z2xkjgrlfk18haq5icbwm6vd8419a03s-source/lib/Crypto/Curve/Secp256k1.hs:990
7e7ef: inc %rbx
7e7f2: or %rbx,%rdi
7e7f5: shr $0x3f,%rdi
7e7f9: cmp $0x1,%rdi
7e7fd: jne 7e943 <+0x440b> branch (taint)
observed by taint: branch, 16× on the secret
Secp256k1.$wecdh z2xkjgrlfk18haq5icbwm6vd8419a03s-source/lib/Crypto/Curve/Secp256k1.hs:990
  978  --   >>> let secret_as_computed_by_alice = ecdh pub_bob sec_alice
  979  --   >>> let secret_as_computed_by_bob   = ecdh pub_alice sec_bob
  980  --   >>> secret_as_computed_by_alice == secret_as_computed_by_bob
  981  --   True
  982  ecdh
  983    :: Projective          -- ^ public key
  984    -> Wider               -- ^ secret key
  985    -> Maybe BS.ByteString -- ^ shared secret
  986  ecdh pub _SECRET = do
  987    pt@(P _ _ (C.Montgomery -> z)) <- mul pub _SECRET
  988    let !(Affine (C.retr -> x) _) = affine pt
  989        !result = SHA256.hash (unroll32 x)
  990    if CT.decide (C.eq z 0) then Nothing else Just result
  991  
  992  -- schnorr --------------------------------------------------------------------
  993  -- see https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki
  994  
  995  -- | Create a 64-byte Schnorr signature for the provided message, using
  996  --   the provided secret key.
  997  --
  998  --   BIP0340 recommends that 32 bytes of fresh auxiliary entropy be
  999  --   generated and added at signing time as additional protection
 1000  --   against side-channel attacks (namely, to thwart so-called "fault
 1001  --   injection" attacks). This entropy is /supplemental/ to security,
 1002  --   and the cryptographic security of the signature scheme itself does
7e803: add $0x40,%r12
7e807: cmp 0x358(%r13),%r12
7e80e: ja 7e862 <+0x432a>
7e810: mov 0x10651(%rip),%rbx # 8ee68 <ghczminternal_GHCziInternalziForeignPtr_PlainPtr_con_info>
source · Secp256k1.hs:990
  986  ecdh pub _SECRET = do
  987    pt@(P _ _ (C.Montgomery -> z)) <- mul pub _SECRET
  988    let !(Affine (C.retr -> x) _) = affine pt
  989        !result = SHA256.hash (unroll32 x)
  990    if CT.decide (C.eq z 0) then Nothing else Just result
  991  
  992  -- schnorr --------------------------------------------------------------------
  993  -- see https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki
  994  
Secp256k1.$wecdhb.ne a35a4 <+0xc6c> // b.anybranch
in Crypto.Curve.Secp256k1.$wecdh
a3508: orr x14, x14, x13
a350c: lsr x14, x14, #63
a3510: mov x13, #0x1 // #1
a3514: cmp x14, x13
a3518: b.ne a35a4 <+0xc6c> // b.any branch (taint)
observed by taint: branch, 16× on the secret
Secp256k1.$wecdh ?
a351c: add x21, x21, #0x40
a3520: ldr x13, [x19, #856]
a3524: cmp x21, x13
a3528: b.hi a3498 <+0xb60> // b.pmore
Secp256k1.$wmuljne 45e82 <+0x392>branchSecp256k1.hs:615
in Crypto.Curve.Secp256k1.$wmul · /build/z2xkjgrlfk18haq5icbwm6vd8419a03s-source/lib/Crypto/Curve/Secp256k1.hs:615
45d7c: or %rax,%r14
45d7f: neg %r14
45d82: and %r11,%r14
45d85: cmp $0xffffffffffffffff,%r14
45d89: jne 45e82 <+0x392> branch (taint)
observed by taint: branch, 16× on the secret
Secp256k1.$wmul z2xkjgrlfk18haq5icbwm6vd8419a03s-source/lib/Crypto/Curve/Secp256k1.hs:615
  603      loop !r !d !m
  604        | zero# m = r
  605        | otherwise =
  606            let !nd = double# d
  607                !(# nm, lsb_set #) = W.shr1_c# m
  608                !nr = if CT.decide lsb_set then add_proj# r d else r
  609            in  loop nr nd nm
  610  {-# INLINE mul_vartime# #-}
  611  
  612  ge# :: Limb4 -> CT.Choice
  613  ge# n =
  614    let !(Wider q) = _CURVE_Q
  615    in  CT.and (W.gt# n Z) (W.lt# n q)
  616  {-# INLINE ge# #-}
  617  
  618  mul_wnaf# :: ByteArray -> Int -> Limb4 -> (# () | Proj #)
  619  mul_wnaf# ctxArray ctxW ls
  620      | CT.decide (CT.not (ge# ls)) = (# () | #)
  621      | otherwise =
  622          let !(P zx zy zz) = _CURVE_ZERO
  623          in  (# | loop 0 (# zx, zy, zz #) ls #)
  624    where
  625      !one                  = (# Limb 1##, Limb 0##, Limb 0##, Limb 0## #)
  626      !wins                 = fi (256 `quot` ctxW + 1)
  627      !size@(GHC.Word.W# s) = 1 .<<. (ctxW - 1)
45d8f: lea 0x1a2(%rip),%rax # 45f38 <+0x448>
45d96: mov %rax,0x80(%rbp)
45d9d: xor %r9d,%r9d
45da0: mov %r8,%rax
source · Secp256k1.hs:615
  611  
  612  ge# :: Limb4 -> CT.Choice
  613  ge# n =
  614    let !(Wider q) = _CURVE_Q
  615    in  CT.and (W.gt# n Z) (W.lt# n q)
  616  {-# INLINE ge# #-}
  617  
  618  mul_wnaf# :: ByteArray -> Int -> Limb4 -> (# () | Proj #)
  619  mul_wnaf# ctxArray ctxW ls
Secp256k1.$wmulb.ne 5a8b8 <+0x558> // b.anybranch
in Crypto.Curve.Secp256k1.$wmul
5a7c0: movk x12, #0xffff, lsl #16
5a7c4: movk x12, #0xffff, lsl #32
5a7c8: movk x12, #0xffff, lsl #48
5a7cc: cmp x13, x12
5a7d0: b.ne 5a8b8 <+0x558> // b.any branch (taint)
observed by taint: branch, 16× on the secret
Secp256k1.$wmul ?
5a7d4: adrp x13, 5a000 <ppadzmsecp256k1zm0zi5zi9zminplace_CryptoziCurveziSecp256k1_precompute_info+0x7208>
5a7d8: add x13, x13, #0x3e4
5a7dc: str x13, [x20, #128]
5a7e0: mov w27, #0x0 // #0
censortiming50000 pairs · α=1.0e-6 · batch 1
test cases
Secp.ecdh (fixed peer) the secret key fixed vs random against one fixed peer point, built before the timed region
host meter result p effect (mean/pair) jitter clip scale clipped
Secp.ecdh (fixed peer)
aarch64-linux instructions ✓ 0.137 [-322, 107] instr 0.0% 2022 instr 79/50000
x86_64-linux instructions ✓ 0.154 [-84, 253] instr 0.0% 1588 instr 78/50000
Secp.ecdh (fixed peer)aarch64-linux
instructions
log(1/α) 0 0
no leak found · 50000 pairs · α=1.0e-6 · p=0.137
Secp.ecdh (fixed peer)x86_64-linux
instructions
log(1/α) 0 0
no leak found · 50000 pairs · α=1.0e-6 · p=0.154

Crypto.Curve.Secp256k1.sign_schnorr

✓ no leak of key or derived nonce found
Signs a fixed message with the secret key (BIP0340)
contract vestigia censor
aarch64
aarch64-linux
arm-dit
✓ 2 invariant ✓ instructions
x86_64
x86_64-linux
intel-doitm
✓ 2 invariant ✓ instructions
vestigiatrace
inputs
secret key pseudorandom in [1, n), n the secp256k1 group order
message 32 bytes, fixed
auxiliary randomness 32 bytes, fixed
no branch or memory address varied with the secret in the code under audit.
✓ invariant · 4 lines the secret reaches, where no run varied
functioninstructionvaries atsource
Secp256k1.$wmuljne 45e82 <+0x392>branchSecp256k1.hs:615
in Crypto.Curve.Secp256k1.$wmul · /build/z2xkjgrlfk18haq5icbwm6vd8419a03s-source/lib/Crypto/Curve/Secp256k1.hs:615
45d7c: or %rax,%r14
45d7f: neg %r14
45d82: and %r11,%r14
45d85: cmp $0xffffffffffffffff,%r14
45d89: jne 45e82 <+0x392> branch (taint)
observed by taint: branch, 32× on the secret
Secp256k1.$wmul z2xkjgrlfk18haq5icbwm6vd8419a03s-source/lib/Crypto/Curve/Secp256k1.hs:615
  603      loop !r !d !m
  604        | zero# m = r
  605        | otherwise =
  606            let !nd = double# d
  607                !(# nm, lsb_set #) = W.shr1_c# m
  608                !nr = if CT.decide lsb_set then add_proj# r d else r
  609            in  loop nr nd nm
  610  {-# INLINE mul_vartime# #-}
  611  
  612  ge# :: Limb4 -> CT.Choice
  613  ge# n =
  614    let !(Wider q) = _CURVE_Q
  615    in  CT.and (W.gt# n Z) (W.lt# n q)
  616  {-# INLINE ge# #-}
  617  
  618  mul_wnaf# :: ByteArray -> Int -> Limb4 -> (# () | Proj #)
  619  mul_wnaf# ctxArray ctxW ls
  620      | CT.decide (CT.not (ge# ls)) = (# () | #)
  621      | otherwise =
  622          let !(P zx zy zz) = _CURVE_ZERO
  623          in  (# | loop 0 (# zx, zy, zz #) ls #)
  624    where
  625      !one                  = (# Limb 1##, Limb 0##, Limb 0##, Limb 0## #)
  626      !wins                 = fi (256 `quot` ctxW + 1)
  627      !size@(GHC.Word.W# s) = 1 .<<. (ctxW - 1)
45d8f: lea 0x1a2(%rip),%rax # 45f38 <+0x448>
45d96: mov %rax,0x80(%rbp)
45d9d: xor %r9d,%r9d
45da0: mov %r8,%rax
source · Secp256k1.hs:615
  611  
  612  ge# :: Limb4 -> CT.Choice
  613  ge# n =
  614    let !(Wider q) = _CURVE_Q
  615    in  CT.and (W.gt# n Z) (W.lt# n q)
  616  {-# INLINE ge# #-}
  617  
  618  mul_wnaf# :: ByteArray -> Int -> Limb4 -> (# () | Proj #)
  619  mul_wnaf# ctxArray ctxW ls
Secp256k1.$wmulb.ne 5a8b8 <+0x558> // b.anybranch
in Crypto.Curve.Secp256k1.$wmul
5a7c0: movk x12, #0xffff, lsl #16
5a7c4: movk x12, #0xffff, lsl #32
5a7c8: movk x12, #0xffff, lsl #48
5a7cc: cmp x13, x12
5a7d0: b.ne 5a8b8 <+0x558> // b.any branch (taint)
observed by taint: branch, 32× on the secret
Secp256k1.$wmul ?
5a7d4: adrp x13, 5a000 <ppadzmsecp256k1zm0zi5zi9zminplace_CryptoziCurveziSecp256k1_precompute_info+0x7208>
5a7d8: add x13, x13, #0x3e4
5a7dc: str x13, [x20, #128]
5a7e0: mov w27, #0x0 // #0
Secp256k1._sign_schnorrje 846fa <+0x27a>branchSecp256k1.hs:1056
in Crypto.Curve.Secp256k1._sign_schnorr · /build/z2xkjgrlfk18haq5icbwm6vd8419a03s-source/lib/Crypto/Curve/Secp256k1.hs:1056
846a6: inc %rbx
846a9: or %rbx,%rdi
846ac: shr $0x3f,%rdi
846b0: cmp $0x1,%rdi
846b4: je 846fa <+0x27a> branch (taint)
observed by taint: branch, 16× on the secret
Secp256k1._sign_schnorr z2xkjgrlfk18haq5icbwm6vd8419a03s-source/lib/Crypto/Curve/Secp256k1.hs:1056
 1044  _sign_schnorr _mul _SECRET m a = do
 1045    p <- _mul _SECRET
 1046    let Affine (C.retr -> x_p) (C.retr -> y_p) = affine p
 1047        s       = S.to _SECRET
 1048        d       = S.select s (negate s) (W.odd y_p)
 1049        bytes_d = unroll32 (S.retr d)
 1050        bytes_p = unroll32 x_p
 1051        t       = xor bytes_d (hash_aux a)
 1052        rand    = hash_nonce (t <> bytes_p <> m)
 1053        k'      = S.to (unsafe_roll32 rand)
 1054    -- negligible probability, but k' is secret, so compare without
 1055    -- short-circuiting and decide only on the result
 1056    guard (not (CT.decide (S.eq k' 0)))
 1057    pt <- _mul (S.retr k')
 1058    let Affine (C.retr -> x_r) (C.retr -> y_r) = affine pt
 1059        k         = S.select k' (negate k') (W.odd y_r)
 1060        bytes_r   = unroll32 x_r
 1061        rand'     = hash_challenge (bytes_r <> bytes_p <> m)
 1062        e         = S.to (unsafe_roll32 rand')
 1063        bytes_ked = unroll32 (S.retr (k + e * d))
 1064        sig       = bytes_r <> bytes_ked
 1065    -- NB for benchmarking we morally want to remove the precautionary
 1066    --    verification check here.
 1067    --
 1068    -- guard (verify_schnorr m p sig)
846b6: add $0x60,%rbp
846ba: mov 0xa7e7(%rip),%rax # 8eea8 <ghczminternal_GHCziInternalziMaybe_Nothing_closure>
846c1: lea 0x1(%rax),%rbx
846c5: add $0x28,%rbp
source · Secp256k1.hs:1056
 1052        rand    = hash_nonce (t <> bytes_p <> m)
 1053        k'      = S.to (unsafe_roll32 rand)
 1054    -- negligible probability, but k' is secret, so compare without
 1055    -- short-circuiting and decide only on the result
 1056    guard (not (CT.decide (S.eq k' 0)))
 1057    pt <- _mul (S.retr k')
 1058    let Affine (C.retr -> x_r) (C.retr -> y_r) = affine pt
 1059        k         = S.select k' (negate k') (W.odd y_r)
 1060        bytes_r   = unroll32 x_r
Secp256k1._sign_schnorrb.eq b0b70 <+0x1890> // b.nonebranch
in Crypto.Curve.Secp256k1._sign_schnorr
b1890: orr x12, x12, x11
b1894: lsr x12, x12, #63
b1898: mov x11, #0x1 // #1
b189c: cmp x12, x11
b18a0: b.eq b0b70 <+0x1890> // b.none branch (taint)
observed by taint: branch, 16× on the secret
Secp256k1._sign_schnorr ?
b18a4: add x20, x20, #0x60
b18a8: b b1830 <+0x2550>
b18ac: .word 0x0bffffd6
b18b0: .word 0x00000000
censortiming50000 pairs · α=1.0e-6 · batch 1
test cases
Secp.sign_schnorr (BIP0340) the secret key fixed vs random over a fixed 32-byte message and auxiliary randomness, so the derived nonce is fixed vs random with it
host meter result p effect (mean/pair) jitter clip scale clipped
Secp.sign_schnorr (BIP0340)
aarch64-linux instructions ✓ 0.484 [-111, 334] instr 0.0% 2092 instr 136/50000
x86_64-linux instructions ✓ 0.845 [-312, 104] instr 0.0% 1958 instr 138/50000
Secp.sign_schnorr (BIP0340)aarch64-linux
instructions
log(1/α) 0 0
no leak found · 50000 pairs · α=1.0e-6 · p=0.484
Secp.sign_schnorr (BIP0340)x86_64-linux
instructions
log(1/α) 0 0
no leak found · 50000 pairs · α=1.0e-6 · p=0.845

Crypto.Curve.Secp256k1.sign_schnorr'

✓ no leak of key or derived nonce found
Signs a fixed message with the secret key (BIP0340), through a precomputed table
contract vestigia censor
aarch64
aarch64-linux
arm-dit
✓ 2 invariant ✓ instructions
x86_64
x86_64-linux
intel-doitm
✓ 2 invariant ✓ instructions
vestigiatrace
inputs
secret key pseudorandom in [1, n), n the secp256k1 group order
message 32 bytes, fixed
auxiliary randomness 32 bytes, fixed
generator context precomputed once, fixed
no branch or memory address varied with the secret in the code under audit.
✓ invariant · 4 lines the secret reaches, where no run varied
functioninstructionvaries atsource
Secp256k1.$wmul_wnafjne 275ce <+0xd9e>branchSecp256k1.hs:615
in Crypto.Curve.Secp256k1.$wmul_wnaf · /build/z2xkjgrlfk18haq5icbwm6vd8419a03s-source/lib/Crypto/Curve/Secp256k1.hs:615
269be: or %rax,%rsi
269c1: neg %rsi
269c4: and %r9,%rsi
269c7: cmp $0xffffffffffffffff,%rsi
269cb: jne 275ce <+0xd9e> branch (taint)
observed by taint: branch, 32× on the secret
Secp256k1.$wmul_wnaf z2xkjgrlfk18haq5icbwm6vd8419a03s-source/lib/Crypto/Curve/Secp256k1.hs:615
  603      loop !r !d !m
  604        | zero# m = r
  605        | otherwise =
  606            let !nd = double# d
  607                !(# nm, lsb_set #) = W.shr1_c# m
  608                !nr = if CT.decide lsb_set then add_proj# r d else r
  609            in  loop nr nd nm
  610  {-# INLINE mul_vartime# #-}
  611  
  612  ge# :: Limb4 -> CT.Choice
  613  ge# n =
  614    let !(Wider q) = _CURVE_Q
  615    in  CT.and (W.gt# n Z) (W.lt# n q)
  616  {-# INLINE ge# #-}
  617  
  618  mul_wnaf# :: ByteArray -> Int -> Limb4 -> (# () | Proj #)
  619  mul_wnaf# ctxArray ctxW ls
  620      | CT.decide (CT.not (ge# ls)) = (# () | #)
  621      | otherwise =
  622          let !(P zx zy zz) = _CURVE_ZERO
  623          in  (# | loop 0 (# zx, zy, zz #) ls #)
  624    where
  625      !one                  = (# Limb 1##, Limb 0##, Limb 0##, Limb 0## #)
  626      !wins                 = fi (256 `quot` ctxW + 1)
  627      !size@(GHC.Word.W# s) = 1 .<<. (ctxW - 1)
269d1: lea 0x28(%rip),%rax # 26a00 <+0x1d0>
269d8: mov %rax,0x0(%rbp)
269dc: lea 0x694cd(%rip),%rbx # 8feb0 <ppadzmsecp256k1zm0zi5zi9zminplace_CryptoziCurveziSecp256k1_zuCURVEzuZZERO4_closure>
269e3: test $0x7,%bl
source · Secp256k1.hs:615
  611  
  612  ge# :: Limb4 -> CT.Choice
  613  ge# n =
  614    let !(Wider q) = _CURVE_Q
  615    in  CT.and (W.gt# n Z) (W.lt# n q)
  616  {-# INLINE ge# #-}
  617  
  618  mul_wnaf# :: ByteArray -> Int -> Limb4 -> (# () | Proj #)
  619  mul_wnaf# ctxArray ctxW ls
Secp256k1.$wmul_wnafb.ne 2da8c <+0x1ddc> // b.anybranch
in Crypto.Curve.Secp256k1.$wmul_wnaf
3232c: movk x17, #0xffff, lsl #16
32330: movk x17, #0xffff, lsl #32
32334: movk x17, #0xffff, lsl #48
32338: cmp x18, x17
3233c: b.ne 2da8c <+0x1ddc> // b.any branch (taint)
observed by taint: branch, 32× on the secret
Secp256k1.$wmul_wnaf ?
32340: adrp x18, 32000 <+0x6350>
32344: add x18, x18, #0x2c
32348: str x18, [x20]
3234c: adrp x22, d0000 <__dso_handle>
Secp256k1.$wsign_schnorr'je 88c28 <+0x260>branchSecp256k1.hs:1056
in Crypto.Curve.Secp256k1.$wsign_schnorr' · /build/z2xkjgrlfk18haq5icbwm6vd8419a03s-source/lib/Crypto/Curve/Secp256k1.hs:1056
88c02: inc %rbx
88c05: or %rbx,%rdi
88c08: shr $0x3f,%rdi
88c0c: cmp $0x1,%rdi
88c10: je 88c28 <+0x260> branch (taint)
observed by taint: branch, 16× on the secret
Secp256k1.$wsign_schnorr' z2xkjgrlfk18haq5icbwm6vd8419a03s-source/lib/Crypto/Curve/Secp256k1.hs:1056
 1044  _sign_schnorr _mul _SECRET m a = do
 1045    p <- _mul _SECRET
 1046    let Affine (C.retr -> x_p) (C.retr -> y_p) = affine p
 1047        s       = S.to _SECRET
 1048        d       = S.select s (negate s) (W.odd y_p)
 1049        bytes_d = unroll32 (S.retr d)
 1050        bytes_p = unroll32 x_p
 1051        t       = xor bytes_d (hash_aux a)
 1052        rand    = hash_nonce (t <> bytes_p <> m)
 1053        k'      = S.to (unsafe_roll32 rand)
 1054    -- negligible probability, but k' is secret, so compare without
 1055    -- short-circuiting and decide only on the result
 1056    guard (not (CT.decide (S.eq k' 0)))
 1057    pt <- _mul (S.retr k')
 1058    let Affine (C.retr -> x_r) (C.retr -> y_r) = affine pt
 1059        k         = S.select k' (negate k') (W.odd y_r)
 1060        bytes_r   = unroll32 x_r
 1061        rand'     = hash_challenge (bytes_r <> bytes_p <> m)
 1062        e         = S.to (unsafe_roll32 rand')
 1063        bytes_ked = unroll32 (S.retr (k + e * d))
 1064        sig       = bytes_r <> bytes_ked
 1065    -- NB for benchmarking we morally want to remove the precautionary
 1066    --    verification check here.
 1067    --
 1068    -- guard (verify_schnorr m p sig)
88c12: add $0x48,%rbp
88c16: mov 0x628b(%rip),%rax # 8eea8 <ghczminternal_GHCziInternalziMaybe_Nothing_closure>
88c1d: lea 0x1(%rax),%rbx
88c21: add $0x48,%rbp
source · Secp256k1.hs:1056
 1052        rand    = hash_nonce (t <> bytes_p <> m)
 1053        k'      = S.to (unsafe_roll32 rand)
 1054    -- negligible probability, but k' is secret, so compare without
 1055    -- short-circuiting and decide only on the result
 1056    guard (not (CT.decide (S.eq k' 0)))
 1057    pt <- _mul (S.retr k')
 1058    let Affine (C.retr -> x_r) (C.retr -> y_r) = affine pt
 1059        k         = S.select k' (negate k') (W.odd y_r)
 1060        bytes_r   = unroll32 x_r
Secp256k1.$wsign_schnorr'b.ne b9228 <+0x25b0> // b.anybranch
in Crypto.Curve.Secp256k1.$wsign_schnorr'
b8508: orr x13, x13, x12
b850c: lsr x13, x13, #63
b8510: mov x12, #0x1 // #1
b8514: cmp x13, x12
b8518: b.ne b9228 <+0x25b0> // b.any branch (taint)
observed by taint: branch, 16× on the secret
Secp256k1.$wsign_schnorr' ?
b851c: ldr x13, [x20, #104]
b8520: ldr x12, [x20, #112]
b8524: mov x11, #0xb13f // #45375
b8528: movk x11, #0x5588, lsl #16
censortiming50000 pairs · α=1.0e-6 · batch 1
test cases
Secp.sign_schnorr' (BIP0340) as sign_schnorr, through one precomputed context
host meter result p effect (mean/pair) jitter clip scale clipped
Secp.sign_schnorr' (BIP0340)
aarch64-linux instructions ✓ 0.621 [-366, 122] instr 0.0% 2294 instr 135/50000
x86_64-linux instructions ✓ 0.060 [-330, 110] instr 0.0% 2072 instr 135/50000
Secp.sign_schnorr' (BIP0340)aarch64-linux
instructions
log(1/α) 0 0
no leak found · 50000 pairs · α=1.0e-6 · p=0.621
Secp.sign_schnorr' (BIP0340)x86_64-linux
instructions
log(1/α) 0 0
no leak found · 50000 pairs · α=1.0e-6 · p=0.060

Crypto.Curve.Secp256k1.sign_ecdsa

✓ no leak of key or deterministic nonce found
Signs a fixed message with the secret key (RFC6979, low s)
contract vestigia censor
aarch64
aarch64-linux
arm-dit
✓ 5 invariant ✓ instructions
x86_64
x86_64-linux
intel-doitm
✓ 5 invariant ✓ instructions
vestigiatrace
inputs
secret key pseudorandom in [1, n), n the secp256k1 group order
message 32 bytes, fixed
no branch or memory address varied with the secret in the code under audit.
✓ invariant · 10 lines the secret reaches, where no run varied
functioninstructionvaries atsource
Secp256k1.$ssign_loopjne 22f7d <+0x4d4d>branchSecp256k1.hs:1320
in Crypto.Curve.Secp256k1.$ssign_loop · /build/z2xkjgrlfk18haq5icbwm6vd8419a03s-source/lib/Crypto/Curve/Secp256k1.hs:1320
22e88: adc $0x0,%rsi
22e8c: add %rsi,%rdx
22e8f: mov 0x60(%rsp),%rbx
22e94: cmp %rbx,%r9
22e97: jne 22f7d <+0x4d4d> branch (taint)
observed by taint: branch, 16× on the secret
? z2xkjgrlfk18haq5icbwm6vd8419a03s-source/lib/Crypto/Curve/Secp256k1.hs:1320
 1308      d  = S.to _SECRET
 1309      hm = S.to (bits2int h)
 1310      h  = case hf of
 1311        Hash -> SHA256.hash m
 1312        NoHash -> m
 1313  
 1314      sign_loop g = do
 1315        k <- gen_k g
 1316        let mpair = do
 1317              kg <- _mul k
 1318              let Affine (S.to . C.retr -> r) _ = affine kg
 1319                  ki = S.inv (S.to k)
 1320                  s  = (hm + d * r) * ki
 1321              pure $! (S.retr r, S.retr s)
 1322        case mpair of
 1323          Nothing -> do
 1324            DRBG.wipe g
 1325            pure Nothing
 1326          Just (r, s)
 1327            -- sec1-v2 4.1.3 retries on either being zero
 1328            | W.eq_vartime r 0 || W.eq_vartime s 0 -> sign_loop g
 1329            | otherwise -> do
 1330                DRBG.wipe g
 1331                let !sig = Just $! ECDSA r s
 1332                pure $ case ty of
22e9d: mov 0x68(%rsp),%rbx
22ea2: cmp %rbx,%r8
22ea5: jne 22f7d <+0x4d4d>
22eab: mov 0x70(%rsp),%rbx
source · Secp256k1.hs:1320
 1316        let mpair = do
 1317              kg <- _mul k
 1318              let Affine (S.to . C.retr -> r) _ = affine kg
 1319                  ki = S.inv (S.to k)
 1320                  s  = (hm + d * r) * ki
 1321              pure $! (S.retr r, S.retr s)
 1322        case mpair of
 1323          Nothing -> do
 1324            DRBG.wipe g
Secp256k1.$ssign_loopjne 23689 <+0x5459>branchSecp256k1.hs:388
in Crypto.Curve.Secp256k1.$ssign_loop · /build/z2xkjgrlfk18haq5icbwm6vd8419a03s-source/lib/Crypto/Curve/Secp256k1.hs:388
23563: adc $0x0,%rsi
23567: add %rsi,%rdx
2356a: mov 0x60(%rsp),%rcx
2356f: cmp %rcx,%r9
23572: jne 23689 <+0x5459> branch (taint)
observed by taint: branch, 16× on the secret
? z2xkjgrlfk18haq5icbwm6vd8419a03s-source/lib/Crypto/Curve/Secp256k1.hs:388
  376          !x2z1 = bx * az
  377          !y1z2 = ay * bz
  378          !y2z1 = by * az
  379      in  CT.decide (CT.and (C.eq x1z2 x2z1) (C.eq y1z2 y2z1))
  380  
  381  -- | A public key, i.e. secp256k1 point.
  382  type Pub = Projective
  383  
  384  -- Convert to affine coordinates.
  385  affine :: Projective -> Affine
  386  affine (Projective x y z) =
  387    let !iz = C.inv z
  388    in  Affine (x * iz) (y * iz)
  389  {-# INLINABLE affine #-}
  390  
  391  -- Convert to projective coordinates.
  392  projective :: Affine -> Projective
  393  projective (Affine x y)
  394    | C.eq_vartime x 0 || C.eq_vartime y 0 = _CURVE_ZERO
  395    | otherwise = Projective x y 1
  396  
  397  -- | secp256k1 generator point.
  398  _CURVE_G :: Projective
  399  _CURVE_G = Projective x y z where
  400    !x = C.Montgomery
23578: mov 0x68(%rsp),%rcx
2357d: cmp %rcx,%r10
23580: jne 23689 <+0x5459>
23586: mov 0x70(%rsp),%rcx
source · Secp256k1.hs:388
  384  -- Convert to affine coordinates.
  385  affine :: Projective -> Affine
  386  affine (Projective x y z) =
  387    let !iz = C.inv z
  388    in  Affine (x * iz) (y * iz)
  389  {-# INLINABLE affine #-}
  390  
  391  -- Convert to projective coordinates.
  392  projective :: Affine -> Projective
Secp256k1.$ssign_loopjne 239c9 <+0x5799>branchSecp256k1.hs:356
in Crypto.Curve.Secp256k1.$ssign_loop · /build/z2xkjgrlfk18haq5icbwm6vd8419a03s-source/lib/Crypto/Curve/Secp256k1.hs:356
2397c: or %rcx,%r8
2397f: neg %r8
23982: and %r11,%r8
23985: test %r8,%r8
23988: jne 239c9 <+0x5799> branch (taint)
observed by taint: branch, 16× on the secret
? z2xkjgrlfk18haq5icbwm6vd8419a03s-source/lib/Crypto/Curve/Secp256k1.hs:356
  344  
  345  -- Is field element?
  346  fe :: Wider -> Bool
  347  fe n = case W.cmp_vartime n 0 of
  348    GT -> case W.cmp_vartime n _CURVE_P of
  349      LT -> True
  350      _  -> False
  351    _ -> False
  352  {-# INLINE fe #-}
  353  
  354  -- Is group element?
  355  ge :: Wider -> Bool
  356  ge (Wider n) = CT.decide (ge# n)
  357  {-# INLINE ge #-}
  358  
  359  -- curve points ---------------------------------------------------------------
  360  
  361  -- curve point, affine coordinates
  362  data Affine = Affine !C.Montgomery !C.Montgomery
  363    deriving stock (Show, Generic)
  364  
  365  -- curve point, projective coordinates
  366  data Projective = Projective {
  367      px :: !C.Montgomery
  368    , py :: !C.Montgomery
2398a: lea 0x4f(%rip),%rax # 239e0 <+0x57b0>
23991: mov %rax,0x8(%rbp)
23995: mov 0x120(%rsp),%rax
source · Secp256k1.hs:356
  352  {-# INLINE fe #-}
  353  
  354  -- Is group element?
  355  ge :: Wider -> Bool
  356  ge (Wider n) = CT.decide (ge# n)
  357  {-# INLINE ge #-}
  358  
  359  -- curve points ---------------------------------------------------------------
  360  
Secp256k1.$wmuljne 45e82 <+0x392>branchSecp256k1.hs:615
in Crypto.Curve.Secp256k1.$wmul · /build/z2xkjgrlfk18haq5icbwm6vd8419a03s-source/lib/Crypto/Curve/Secp256k1.hs:615
45d7c: or %rax,%r14
45d7f: neg %r14
45d82: and %r11,%r14
45d85: cmp $0xffffffffffffffff,%r14
45d89: jne 45e82 <+0x392> branch (taint)
observed by taint: branch, 16× on the secret
Secp256k1.$wmul z2xkjgrlfk18haq5icbwm6vd8419a03s-source/lib/Crypto/Curve/Secp256k1.hs:615
  603      loop !r !d !m
  604        | zero# m = r
  605        | otherwise =
  606            let !nd = double# d
  607                !(# nm, lsb_set #) = W.shr1_c# m
  608                !nr = if CT.decide lsb_set then add_proj# r d else r
  609            in  loop nr nd nm
  610  {-# INLINE mul_vartime# #-}
  611  
  612  ge# :: Limb4 -> CT.Choice
  613  ge# n =
  614    let !(Wider q) = _CURVE_Q
  615    in  CT.and (W.gt# n Z) (W.lt# n q)
  616  {-# INLINE ge# #-}
  617  
  618  mul_wnaf# :: ByteArray -> Int -> Limb4 -> (# () | Proj #)
  619  mul_wnaf# ctxArray ctxW ls
  620      | CT.decide (CT.not (ge# ls)) = (# () | #)
  621      | otherwise =
  622          let !(P zx zy zz) = _CURVE_ZERO
  623          in  (# | loop 0 (# zx, zy, zz #) ls #)
  624    where
  625      !one                  = (# Limb 1##, Limb 0##, Limb 0##, Limb 0## #)
  626      !wins                 = fi (256 `quot` ctxW + 1)
  627      !size@(GHC.Word.W# s) = 1 .<<. (ctxW - 1)
45d8f: lea 0x1a2(%rip),%rax # 45f38 <+0x448>
45d96: mov %rax,0x80(%rbp)
45d9d: xor %r9d,%r9d
45da0: mov %r8,%rax
source · Secp256k1.hs:615
  611  
  612  ge# :: Limb4 -> CT.Choice
  613  ge# n =
  614    let !(Wider q) = _CURVE_Q
  615    in  CT.and (W.gt# n Z) (W.lt# n q)
  616  {-# INLINE ge# #-}
  617  
  618  mul_wnaf# :: ByteArray -> Int -> Limb4 -> (# () | Proj #)
  619  mul_wnaf# ctxArray ctxW ls
Secp256k1.$wmulb.ne 5a8b8 <+0x558> // b.anybranch
in Crypto.Curve.Secp256k1.$wmul
5a7c0: movk x12, #0xffff, lsl #16
5a7c4: movk x12, #0xffff, lsl #32
5a7c8: movk x12, #0xffff, lsl #48
5a7cc: cmp x13, x12
5a7d0: b.ne 5a8b8 <+0x558> // b.any branch (taint)
observed by taint: branch, 16× on the secret
Secp256k1.$wmul ?
5a7d4: adrp x13, 5a000 <ppadzmsecp256k1zm0zi5zi9zminplace_CryptoziCurveziSecp256k1_precompute_info+0x7208>
5a7d8: add x13, x13, #0x3e4
5a7dc: str x13, [x20, #128]
5a7e0: mov w27, #0x0 // #0
Secp256k1._sign_ecdsajne 23e0e <+0x1de>branchSecp256k1.hs:615
in Crypto.Curve.Secp256k1._sign_ecdsa · /build/z2xkjgrlfk18haq5icbwm6vd8419a03s-source/lib/Crypto/Curve/Secp256k1.hs:615
23dee: or %rcx,%r11
23df1: neg %r11
23df4: and %r14,%r11
23df7: test %r11,%r11
23dfa: jne 23e0e <+0x1de> branch (taint)
observed by taint: branch, 16× on the secret
Secp256k1._sign_ecdsa z2xkjgrlfk18haq5icbwm6vd8419a03s-source/lib/Crypto/Curve/Secp256k1.hs:615
  603      loop !r !d !m
  604        | zero# m = r
  605        | otherwise =
  606            let !nd = double# d
  607                !(# nm, lsb_set #) = W.shr1_c# m
  608                !nr = if CT.decide lsb_set then add_proj# r d else r
  609            in  loop nr nd nm
  610  {-# INLINE mul_vartime# #-}
  611  
  612  ge# :: Limb4 -> CT.Choice
  613  ge# n =
  614    let !(Wider q) = _CURVE_Q
  615    in  CT.and (W.gt# n Z) (W.lt# n q)
  616  {-# INLINE ge# #-}
  617  
  618  mul_wnaf# :: ByteArray -> Int -> Limb4 -> (# () | Proj #)
  619  mul_wnaf# ctxArray ctxW ls
  620      | CT.decide (CT.not (ge# ls)) = (# () | #)
  621      | otherwise =
  622          let !(P zx zy zz) = _CURVE_ZERO
  623          in  (# | loop 0 (# zx, zy, zz #) ls #)
  624    where
  625      !one                  = (# Limb 1##, Limb 0##, Limb 0##, Limb 0## #)
  626      !wins                 = fi (256 `quot` ctxW + 1)
  627      !size@(GHC.Word.W# s) = 1 .<<. (ctxW - 1)
23dfc: mov 0x6b0a5(%rip),%rax # 8eea8 <ghczminternal_GHCziInternalziMaybe_Nothing_closure>
23e03: lea 0x1(%rax),%rbx
23e07: add $0x48,%rbp
23e0b: jmp *0x0(%rbp)
source · Secp256k1.hs:615
  611  
  612  ge# :: Limb4 -> CT.Choice
  613  ge# n =
  614    let !(Wider q) = _CURVE_Q
  615    in  CT.and (W.gt# n Z) (W.lt# n q)
  616  {-# INLINE ge# #-}
  617  
  618  mul_wnaf# :: ByteArray -> Int -> Limb4 -> (# () | Proj #)
  619  mul_wnaf# ctxArray ctxW ls
Secp256k1._sign_ecdsacbnz x9, 278fc <+0x69c>branch
in Crypto.Curve.Secp256k1._sign_ecdsa
27608: lsr x9, x9, #63
2760c: orr x9, x6, x9
27610: neg x9, x9
27614: and x9, x7, x9
27618: cbnz x9, 278fc <+0x69c> branch (taint)
observed by taint: branch, 16× on the secret
Secp256k1._sign_ecdsa ?
2761c: adrp x22, cf000 <__FRAME_END__+0xfdb0>
27620: ldr x22, [x22, #3600]
27624: add x22, x22, #0x1
27628: add x20, x20, #0x48
Secp256k1.even_y_vartimecbnz x13, 20634 <+0x1514>branch
in Crypto.Curve.Secp256k1.even_y_vartime
20260: lsr x13, x13, #63
20264: orr x13, x10, x13
20268: neg x13, x13
2026c: and x13, x11, x13
20270: cbnz x13, 20634 <+0x1514> branch (taint)
observed by taint: branch, 16× on the secret
? ?
20274: ldr x13, [x20, #8]
20278: adrp x12, 20000 <+0xee0>
2027c: add x12, x12, #0x5c4
20280: str x12, [x20, #8]
Secp256k1.even_y_vartimeb.ne 20348 <+0x1228> // b.anybranch
in Crypto.Curve.Secp256k1.even_y_vartime
212fc: lsr x18, x18, #32
21300: add x18, x15, x18
21304: ldr x15, [sp, #48]
21308: cmp x9, x15
2130c: b.ne 20348 <+0x1228> // b.any branch (taint)
observed by taint: branch, 16× on the secret
? ?
21310: ldr x15, [sp, #56]
21314: cmp x13, x15
21318: b.ne 20348 <+0x1228> // b.any
2131c: ldr x15, [sp, #64]
Secp256k1.even_y_vartimeb.ne 26590 <+0x7470> // b.anybranch
in Crypto.Curve.Secp256k1.even_y_vartime
21f94: lsr x18, x18, #32
21f98: add x18, x17, x18
21f9c: ldr x17, [sp, #48]
21fa0: cmp x12, x17
21fa4: b.ne 26590 <+0x7470> // b.any branch (taint)
observed by taint: branch, 16× on the secret
? ?
21fa8: ldr x17, [sp, #56]
21fac: cmp x14, x17
21fb0: b.ne 26590 <+0x7470> // b.any
21fb4: ldr x17, [sp, #64]
censortiming50000 pairs · α=1.0e-6 · batch 1
test cases
Secp.sign_ecdsa (RFC6979) the secret key fixed vs random over a fixed 32-byte message, so the RFC6979 nonce is fixed vs random with it
host meter result p effect (mean/pair) jitter clip scale clipped
Secp.sign_ecdsa (RFC6979)
aarch64-linux instructions ✓ 0.138 [-115, 345] instr 0.0% 2164 instr 97/50000
x86_64-linux instructions ✓ 0.440 [-95, 286] instr 0.0% 1796 instr 111/50000
Secp.sign_ecdsa (RFC6979)aarch64-linux
instructions
log(1/α) 0 0
no leak found · 50000 pairs · α=1.0e-6 · p=0.138
Secp.sign_ecdsa (RFC6979)x86_64-linux
instructions
log(1/α) 0 0
no leak found · 50000 pairs · α=1.0e-6 · p=0.440

Crypto.Curve.Secp256k1.sign_ecdsa'

✓ no leak of key or deterministic nonce found
Signs a fixed message with the secret key (RFC6979, low s), through a precomputed table
contract vestigia censor
aarch64
aarch64-linux
arm-dit
✓ 5 invariant ✓ instructions
x86_64
x86_64-linux
intel-doitm
✓ 5 invariant ✓ instructions
vestigiatrace
inputs
secret key pseudorandom in [1, n), n the secp256k1 group order
message 32 bytes, fixed
generator context precomputed once, fixed
no branch or memory address varied with the secret in the code under audit.
✓ invariant · 10 lines the secret reaches, where no run varied
functioninstructionvaries atsource
Secp256k1.$ssign_loopjne 2b2c1 <+0x3f9>branchSecp256k1.hs:356
in Crypto.Curve.Secp256k1.$ssign_loop · /build/z2xkjgrlfk18haq5icbwm6vd8419a03s-source/lib/Crypto/Curve/Secp256k1.hs:356
2b274: or %rcx,%r8
2b277: neg %r8
2b27a: and %r11,%r8
2b27d: test %r8,%r8
2b280: jne 2b2c1 <+0x3f9> branch (taint)
observed by taint: branch, 16× on the secret
? z2xkjgrlfk18haq5icbwm6vd8419a03s-source/lib/Crypto/Curve/Secp256k1.hs:356
  344  
  345  -- Is field element?
  346  fe :: Wider -> Bool
  347  fe n = case W.cmp_vartime n 0 of
  348    GT -> case W.cmp_vartime n _CURVE_P of
  349      LT -> True
  350      _  -> False
  351    _ -> False
  352  {-# INLINE fe #-}
  353  
  354  -- Is group element?
  355  ge :: Wider -> Bool
  356  ge (Wider n) = CT.decide (ge# n)
  357  {-# INLINE ge #-}
  358  
  359  -- curve points ---------------------------------------------------------------
  360  
  361  -- curve point, affine coordinates
  362  data Affine = Affine !C.Montgomery !C.Montgomery
  363    deriving stock (Show, Generic)
  364  
  365  -- curve point, projective coordinates
  366  data Projective = Projective {
  367      px :: !C.Montgomery
  368    , py :: !C.Montgomery
2b282: lea 0x4f(%rip),%rax # 2b2d8 <+0x410>
2b289: mov %rax,0x8(%rbp)
2b28d: mov 0x140(%rsp),%rax
source · Secp256k1.hs:356
  352  {-# INLINE fe #-}
  353  
  354  -- Is group element?
  355  ge :: Wider -> Bool
  356  ge (Wider n) = CT.decide (ge# n)
  357  {-# INLINE ge #-}
  358  
  359  -- curve points ---------------------------------------------------------------
  360  
Secp256k1.$ssign_loopjne 3023b <+0x5373>branchSecp256k1.hs:1320
in Crypto.Curve.Secp256k1.$ssign_loop · /build/z2xkjgrlfk18haq5icbwm6vd8419a03s-source/lib/Crypto/Curve/Secp256k1.hs:1320
30152: adc $0x0,%rcx
30156: add %rcx,%rdx
30159: mov 0x60(%rsp),%rbx
3015e: cmp %rbx,%r9
30161: jne 3023b <+0x5373> branch (taint)
observed by taint: branch, 16× on the secret
? z2xkjgrlfk18haq5icbwm6vd8419a03s-source/lib/Crypto/Curve/Secp256k1.hs:1320
 1308      d  = S.to _SECRET
 1309      hm = S.to (bits2int h)
 1310      h  = case hf of
 1311        Hash -> SHA256.hash m
 1312        NoHash -> m
 1313  
 1314      sign_loop g = do
 1315        k <- gen_k g
 1316        let mpair = do
 1317              kg <- _mul k
 1318              let Affine (S.to . C.retr -> r) _ = affine kg
 1319                  ki = S.inv (S.to k)
 1320                  s  = (hm + d * r) * ki
 1321              pure $! (S.retr r, S.retr s)
 1322        case mpair of
 1323          Nothing -> do
 1324            DRBG.wipe g
 1325            pure Nothing
 1326          Just (r, s)
 1327            -- sec1-v2 4.1.3 retries on either being zero
 1328            | W.eq_vartime r 0 || W.eq_vartime s 0 -> sign_loop g
 1329            | otherwise -> do
 1330                DRBG.wipe g
 1331                let !sig = Just $! ECDSA r s
 1332                pure $ case ty of
30167: mov 0x68(%rsp),%rbx
3016c: cmp %rbx,%r8
3016f: jne 3023b <+0x5373>
30175: mov 0x70(%rsp),%rbx
source · Secp256k1.hs:1320
 1316        let mpair = do
 1317              kg <- _mul k
 1318              let Affine (S.to . C.retr -> r) _ = affine kg
 1319                  ki = S.inv (S.to k)
 1320                  s  = (hm + d * r) * ki
 1321              pure $! (S.retr r, S.retr s)
 1322        case mpair of
 1323          Nothing -> do
 1324            DRBG.wipe g
Secp256k1.$ssign_loopjne 2afae <+0xe6>branchSecp256k1.hs:388
in Crypto.Curve.Secp256k1.$ssign_loop · /build/z2xkjgrlfk18haq5icbwm6vd8419a03s-source/lib/Crypto/Curve/Secp256k1.hs:388
30828: adc $0x0,%rsi
3082c: add %rsi,%rdx
3082f: mov 0x60(%rsp),%rcx
30834: cmp %rcx,%r9
30837: jne 2afae <+0xe6> branch (taint)
observed by taint: branch, 16× on the secret
? z2xkjgrlfk18haq5icbwm6vd8419a03s-source/lib/Crypto/Curve/Secp256k1.hs:388
  376          !x2z1 = bx * az
  377          !y1z2 = ay * bz
  378          !y2z1 = by * az
  379      in  CT.decide (CT.and (C.eq x1z2 x2z1) (C.eq y1z2 y2z1))
  380  
  381  -- | A public key, i.e. secp256k1 point.
  382  type Pub = Projective
  383  
  384  -- Convert to affine coordinates.
  385  affine :: Projective -> Affine
  386  affine (Projective x y z) =
  387    let !iz = C.inv z
  388    in  Affine (x * iz) (y * iz)
  389  {-# INLINABLE affine #-}
  390  
  391  -- Convert to projective coordinates.
  392  projective :: Affine -> Projective
  393  projective (Affine x y)
  394    | C.eq_vartime x 0 || C.eq_vartime y 0 = _CURVE_ZERO
  395    | otherwise = Projective x y 1
  396  
  397  -- | secp256k1 generator point.
  398  _CURVE_G :: Projective
  399  _CURVE_G = Projective x y z where
  400    !x = C.Montgomery
3083d: mov 0x68(%rsp),%rcx
30842: cmp %rcx,%r10
30845: jne 2afae <+0xe6>
3084b: mov 0x70(%rsp),%rcx
source · Secp256k1.hs:388
  384  -- Convert to affine coordinates.
  385  affine :: Projective -> Affine
  386  affine (Projective x y z) =
  387    let !iz = C.inv z
  388    in  Affine (x * iz) (y * iz)
  389  {-# INLINABLE affine #-}
  390  
  391  -- Convert to projective coordinates.
  392  projective :: Affine -> Projective
Secp256k1.$wmul_wnafjne 275ce <+0xd9e>branchSecp256k1.hs:615
in Crypto.Curve.Secp256k1.$wmul_wnaf · /build/z2xkjgrlfk18haq5icbwm6vd8419a03s-source/lib/Crypto/Curve/Secp256k1.hs:615
269be: or %rax,%rsi
269c1: neg %rsi
269c4: and %r9,%rsi
269c7: cmp $0xffffffffffffffff,%rsi
269cb: jne 275ce <+0xd9e> branch (taint)
observed by taint: branch, 16× on the secret
Secp256k1.$wmul_wnaf z2xkjgrlfk18haq5icbwm6vd8419a03s-source/lib/Crypto/Curve/Secp256k1.hs:615
  603      loop !r !d !m
  604        | zero# m = r
  605        | otherwise =
  606            let !nd = double# d
  607                !(# nm, lsb_set #) = W.shr1_c# m
  608                !nr = if CT.decide lsb_set then add_proj# r d else r
  609            in  loop nr nd nm
  610  {-# INLINE mul_vartime# #-}
  611  
  612  ge# :: Limb4 -> CT.Choice
  613  ge# n =
  614    let !(Wider q) = _CURVE_Q
  615    in  CT.and (W.gt# n Z) (W.lt# n q)
  616  {-# INLINE ge# #-}
  617  
  618  mul_wnaf# :: ByteArray -> Int -> Limb4 -> (# () | Proj #)
  619  mul_wnaf# ctxArray ctxW ls
  620      | CT.decide (CT.not (ge# ls)) = (# () | #)
  621      | otherwise =
  622          let !(P zx zy zz) = _CURVE_ZERO
  623          in  (# | loop 0 (# zx, zy, zz #) ls #)
  624    where
  625      !one                  = (# Limb 1##, Limb 0##, Limb 0##, Limb 0## #)
  626      !wins                 = fi (256 `quot` ctxW + 1)
  627      !size@(GHC.Word.W# s) = 1 .<<. (ctxW - 1)
269d1: lea 0x28(%rip),%rax # 26a00 <+0x1d0>
269d8: mov %rax,0x0(%rbp)
269dc: lea 0x694cd(%rip),%rbx # 8feb0 <ppadzmsecp256k1zm0zi5zi9zminplace_CryptoziCurveziSecp256k1_zuCURVEzuZZERO4_closure>
269e3: test $0x7,%bl
source · Secp256k1.hs:615
  611  
  612  ge# :: Limb4 -> CT.Choice
  613  ge# n =
  614    let !(Wider q) = _CURVE_Q
  615    in  CT.and (W.gt# n Z) (W.lt# n q)
  616  {-# INLINE ge# #-}
  617  
  618  mul_wnaf# :: ByteArray -> Int -> Limb4 -> (# () | Proj #)
  619  mul_wnaf# ctxArray ctxW ls
Secp256k1.$wmul_wnafb.ne 2da8c <+0x1ddc> // b.anybranch
in Crypto.Curve.Secp256k1.$wmul_wnaf
3232c: movk x17, #0xffff, lsl #16
32330: movk x17, #0xffff, lsl #32
32334: movk x17, #0xffff, lsl #48
32338: cmp x18, x17
3233c: b.ne 2da8c <+0x1ddc> // b.any branch (taint)
observed by taint: branch, 16× on the secret
Secp256k1.$wmul_wnaf ?
32340: adrp x18, 32000 <+0x6350>
32344: add x18, x18, #0x2c
32348: str x18, [x20]
3234c: adrp x22, d0000 <__dso_handle>
Secp256k1.$wsign_ecdsa'jne 30a3e <+0x18e>branchSecp256k1.hs:1234
in Crypto.Curve.Secp256k1.$wsign_ecdsa' · /build/z2xkjgrlfk18haq5icbwm6vd8419a03s-source/lib/Crypto/Curve/Secp256k1.hs:1234
30a1e: or %rcx,%r11
30a21: neg %r11
30a24: and %r14,%r11
30a27: test %r11,%r11
30a2a: jne 30a3e <+0x18e> branch (taint)
observed by taint: branch, 16× on the secret
Secp256k1.$wsign_ecdsa' z2xkjgrlfk18haq5icbwm6vd8419a03s-source/lib/Crypto/Curve/Secp256k1.hs:1234
 1222  --
 1223  --   You can expect about a 10x performance increase when using this
 1224  --   function, compared to 'sign_ecdsa'.
 1225  --
 1226  --   >>> let !tex = precompute
 1227  --   >>> sign_ecdsa' tex sec msg
 1228  --   Just "<ecdsa signature>"
 1229  sign_ecdsa'
 1230    :: Context       -- ^ secp256k1 context
 1231    -> Wider         -- ^ secret key
 1232    -> BS.ByteString -- ^ message
 1233    -> Maybe ECDSA
 1234  sign_ecdsa' tex = _sign_ecdsa (mul_wnaf tex) LowS Hash
 1235  
 1236  -- | Produce an ECDSA signature for the provided message, using the
 1237  --   provided private key.
 1238  --
 1239  --   'sign_ecdsa_unrestricted' produces an unrestricted ECDSA signature,
 1240  --   which is less common in applications using secp256k1 due to the
 1241  --   signature's inherent malleability. If you need a conventional
 1242  --   "low-s" signature, use 'sign_ecdsa'.
 1243  --
 1244  --   >>> sign_ecdsa_unrestricted sec msg
 1245  --   Just "<ecdsa signature>"
 1246  sign_ecdsa_unrestricted
30a2c: mov 0x5e475(%rip),%rax # 8eea8 <ghczminternal_GHCziInternalziMaybe_Nothing_closure>
30a33: lea 0x1(%rax),%rbx
30a37: add $0x38,%rbp
30a3b: jmp *0x0(%rbp)
source · Secp256k1.hs:1234
 1230    :: Context       -- ^ secp256k1 context
 1231    -> Wider         -- ^ secret key
 1232    -> BS.ByteString -- ^ message
 1233    -> Maybe ECDSA
 1234  sign_ecdsa' tex = _sign_ecdsa (mul_wnaf tex) LowS Hash
 1235  
 1236  -- | Produce an ECDSA signature for the provided message, using the
 1237  --   provided private key.
 1238  --
Secp256k1.$wsign_ecdsa'cbnz x13, 3a18c <+0x78b4>branch
in Crypto.Curve.Secp256k1.$wsign_ecdsa'
332b0: lsr x13, x13, #63
332b4: orr x13, x10, x13
332b8: neg x13, x13
332bc: and x13, x11, x13
332c0: cbnz x13, 3a18c <+0x78b4> branch (taint)
observed by taint: branch, 16× on the secret
? ?
332c4: ldr x13, [x20, #8]
332c8: adrp x12, 3a000 <+0x7728>
332cc: add x12, x12, #0x140
332d0: str x12, [x20, #8]
Secp256k1.$wsign_ecdsa'b.ne 33390 <+0xab8> // b.anybranch
in Crypto.Curve.Secp256k1.$wsign_ecdsa'
34258: lsr x18, x18, #32
3425c: add x18, x17, x18
34260: ldr x17, [sp, #48]
34264: cmp x10, x17
34268: b.ne 33390 <+0xab8> // b.any branch (taint)
observed by taint: branch, 16× on the secret
? ?
3426c: ldr x17, [sp, #56]
34270: cmp x13, x17
34274: b.ne 33390 <+0xab8> // b.any
34278: ldr x17, [sp, #72]
Secp256k1.$wsign_ecdsa'b.ne 394ec <+0x6c14> // b.anybranch
in Crypto.Curve.Secp256k1.$wsign_ecdsa'
34ef0: lsr x18, x18, #32
34ef4: add x18, x17, x18
34ef8: ldr x17, [sp, #48]
34efc: cmp x12, x17
34f00: b.ne 394ec <+0x6c14> // b.any branch (taint)
observed by taint: branch, 16× on the secret
? ?
34f04: ldr x17, [sp, #56]
34f08: cmp x14, x17
34f0c: b.ne 394ec <+0x6c14> // b.any
34f10: ldr x17, [sp, #72]
Secp256k1.$wsign_ecdsa'cbnz x9, 3a900 <+0x680>branch
in Crypto.Curve.Secp256k1.$wsign_ecdsa'
3a614: lsr x9, x9, #63
3a618: orr x9, x6, x9
3a61c: neg x9, x9
3a620: and x9, x7, x9
3a624: cbnz x9, 3a900 <+0x680> branch (taint)
observed by taint: branch, 16× on the secret
Secp256k1.$wsign_ecdsa' ?
3a628: adrp x22, cf000 <__FRAME_END__+0xfdb0>
3a62c: ldr x22, [x22, #3600]
3a630: add x22, x22, #0x1
3a634: add x20, x20, #0x38
censortiming50000 pairs · α=1.0e-6 · batch 1
test cases
Secp.sign_ecdsa' (RFC6979) as sign_ecdsa, through one precomputed context
host meter result p effect (mean/pair) jitter clip scale clipped
Secp.sign_ecdsa' (RFC6979)
aarch64-linux instructions ✓ 0.761 [-108, 323] instr 0.0% 2026 instr 107/50000
x86_64-linux instructions ✓ 0.026 [-247, 82] instr 0.0% 1552 instr 99/50000
Secp.sign_ecdsa' (RFC6979)aarch64-linux
instructions
log(1/α) 0 0
no leak found · 50000 pairs · α=1.0e-6 · p=0.761
Secp.sign_ecdsa' (RFC6979)x86_64-linux
instructions
log(1/α) 0 0
no leak found · 50000 pairs · α=1.0e-6 · p=0.026

appendix

method
adversary and security property

This analysis assumes an adversary who can call the analysed functions any number of times, on public inputs of its choosing, and observe their execution at the architectural level, i.e.

  • which instructions run, and so which branches are taken and how many instructions retire;
  • which memory addresses are accessed, e.g. through a shared cache; and
  • how long each instruction takes.

Under the ISA's data-independent-timing (DIT) contract, an instruction it covers takes a time independent of its data, so a clock adds no additional information there. For one it does not cover, the analysis takes the instruction's operands as a conservative stand-in for its time: where they vary with the secret, the property may fail, but the analysis cannot show that it does.

For any analysed function, the security property of concern is thus that its execution, as observed by the adversary, is constant with respect to its declared secrets. Or, put somewhat more formally: for a function f, with secret values s0, s1, and public input p, the adversary's observation O of its execution is identically distributed under (s0, p) and (s1, p), up to renaming of base pointers and stack addresses:

O(f, s0, p) ~ O(f, s1, p)

Microarchitectural concerns (including whether the mode the contract requires is set), physical concerns (e.g. power and electromagnetic emanation), and speculative execution concerns are considered out of scope.

approach

The above security property is assumed, and then scrutinized in two ways:

vestigia v0.2.2 performs both taint and differential execution trace analyses. The former maps every branch and address computed from declared secrets on the path one secret takes through the function, and the latter compares traces, executed under emulation, that vary only in declared secrets, against a second run of one secret as a control. Any difference the control doesn't share directly negates the property.

censor v0.6.0 runs the function natively on many paired inputs, one class with the declared secrets fixed and the other drawing them fresh, and tests whether the number of instructions retired differs between the classes. A rejection whose controls pass is evidence that the security property doesn't hold.

The analysis is limited primarily by reachability, i.e. whether the variation in inputs yields satisfactory exploration of the trace space, or whether taint propagates faithfully. The analysis can thus falsify the assumed security property by finding a witness, but it cannot prove it.

Of note, an instruction outside the ISA's contract that runs on operands that vary with the secret is not a witness, as whether its time follows its operands is a microarchitectural concern, deemed out of scope. A division is taken to leak its operands, its latency being documented to depend on them.

vestigia

A line is the set of instructions that one source line of one function compiled to, and is the unit by which the report reads a trace. A line varied if, between runs that differ only in the declared secrets, one of its branches had outcomes that differed in proportion or order, or one of its memory accesses had different addresses. An instruction outside the ISA's contract whose operands varied with the secret is read by what is known of its timing: a division, whose time is documented to depend on its operands, is a leak; any other leaves its line outside any DIT contract. Each line shown falls into one of three classes:

  • leak: the line varied, or a division there ran on operands that varied, and it is a witness against the security property.
  • outside any DIT contract: some other instruction outside the ISA's contract ran there on operands that varied with the secret. It is not a witness, but it is not cleared either; the contract says nothing about the instruction's time, so a finding of no leak holds everywhere but there.
  • invariant: the taint analysis finds that the secret reaches the line, but no run varied there. It is not a witness, though a variation the compared secrets did not trigger could still hide there.

The header gives the number of distinct secret values the differential runs compared, for each execution on each system, beside a repeated run of one of them as the control: pseudorandom valid secrets, sampled deterministically from a fixed seed. What an execution's traces ran on, its secrets' domain and any input held fixed, is listed under its vestigia lane. Rare cases may thus remain undetected. Each execution's evidence table gives, per ISA, the contract its runs were recorded under.

A line opens onto its assembly, with each instruction the secret reached marked by what observed it: the analysis, what it saw (a branch, a memory address, a system call, or an operand), and how often. Under the differential runs that is how many times the instruction ran; under taint, how many times it ran on data computed from the secret. Each marked instruction opens onto its stack, and each frame onto the source around it. The assembly is the build's own disassembly, located by the digest of the object each run executed, and the source comes from the same build's line tables, so the instruction shown is the one that ran.

censor

Each test case is one hypothesis about an execution: which declared secrets one class of inputs fixes and the other draws fresh, with any public inputs drawn alike in both. The cases are listed under each execution's censor lane. A case times the two classes on paired inputs, in random order, one pair at a time; batch is how many calls each reading spans. Under the instructions meter a reading is the number of instructions the function retired, which its code and inputs alone determine, so no host's noise enters it, and jitter, a call's interquartile range over its median, is near zero.

The test is sequential and anytime-valid. Evidence against the hypothesis of no difference accumulates pair by pair, as the log e-value plotted over pairs, and the case rejects if it crosses log(1/α). The p shown is anytime-valid too, so when the run stopped does not inflate it. Each pair's difference is clipped at a scale c (the clip scale) set during warmup, so a rare extreme reading can neither force nor mask a rejection; clipped counts the pairs that reached it. The effect is the anytime-valid confidence interval for the clipped mean difference per pair, plotted as a band narrowing over pairs; one that straddles zero is consistent with no difference.

A rejection counts only where censor's controls, rerun on it, pass: A/A and B/B runs, each class against itself, which can implicate the harness, though not exonerate it. Its driver names what the evidence rested on: a shift in the mean, an asymmetry, rare outliers, a difference in spread, or several at once. A pass means no evidence was found within the budget of pairs, on that host and meter, and is qualified (†) where censor found the evidence weak: high clipping, where many pairs reached the clip scale, or low power, where the effect interval stayed wide against it. The provenance's run totals give each run's family-wise α: a bound on the chance of any false rejection among its cases.

this report

measure v0.6.10 checks the evidence before rendering it: every function's bindings to its cases must resolve, the censor runs must share one configuration, with one run per ISA and meter, the verdict must be the one the policy gate and its signed components imply, and each component must agree with the cells where both read the same evidence. Nothing quantitative is recomputed.

provenance
target
ppad-secp256k1 0.5.9 (b3494fafaebc51b991638721a2a5870138e1dc79)
source
https://git.ppad.tech/secp256k1
seed
0x5eed5eed5eed5eed
censor config
alpha=1.0e-6, budget=50000, warmup=500, batch=per-case
run environments
aarch64-linux · instructions
Cortex-A72 (4 cores) · linux 6.18.34 · 2026-11-03T13:13:58Z
x86_64-linux · instructions
AMD EPYC 7713 64-Core Processor (6 cores) · linux 6.18.57 · 2026-11-03T13:29:17Z
run totals
aarch64-linux · instructions
9 cases · 450000 pairs · 0 reject · α=1.0e-6 · family α=9.0e-6
x86_64-linux · instructions
9 cases · 450000 pairs · 0 reject · α=1.0e-6 · family α=9.0e-6
journal
plan d9f39eba8423 · 2026-11-03 09:32–09:32 UTC · re-baselined by 21242e16734c
2026-11-03 UTC
09:32:24 plan 2 cells · 2 runs · plan d9f39eba8423
plan 21242e16734c · 2026-11-03 12:11–13:35 UTC
2026-11-03 UTC
12:11:41 plan 2 cells · 2 runs · plan 21242e16734c · re-baselined from d9f39eba8423
12:11:41 build ppad-secp256k1/aarch64-linux/ghc-9.10.3/ncg/O2 — 2m23s · store x8alrfsb
12:14:04 build ppad-secp256k1/x86_64-linux/ghc-9.10.3/ncg/O2 — 1m30s · store rmf9lvhp
12:15:34 build censor/secp256k1-secret-scalar-instructions/aarch64-linux/instructions — 24s · store kc0km5s1
12:15:58 build censor/secp256k1-secret-scalar-instructions/x86_64-linux/instructions — 2m12s · store 8px1r5ls
12:18:11 vestigia derive_pub/aarch64-linux/diff/a72 — 2m · store vkm4msr9
12:20:11 vestigia derive_pub/aarch64-linux/taint — 1m58s · store k10dbzxn
12:22:09 vestigia derive_pub/x86_64-linux/diff/zen3 — 1m41s · store fw93vgcy
12:23:50 vestigia derive_pub/x86_64-linux/taint — 1m3s · store n05jwpif
12:24:53 vestigia derive_pub_ctx/aarch64-linux/diff/a72 — 1m35s · store j4lyzqma
12:26:28 vestigia derive_pub_ctx/aarch64-linux/taint — 1m57s · store ihxmy2mg
12:28:25 vestigia derive_pub_ctx/x86_64-linux/diff/zen3 — 45s · store 0x032rxb
12:29:10 vestigia derive_pub_ctx/x86_64-linux/taint — 51s · store h07r536v
12:30:01 vestigia ecdh/aarch64-linux/diff/a72 — 1m56s · store hm0hhck8
12:31:57 vestigia ecdh/aarch64-linux/taint — 1m58s · store zji18jha
12:33:55 vestigia ecdh/x86_64-linux/diff/zen3 — 51s · store 2bjmdmdk
12:34:46 vestigia ecdh/x86_64-linux/taint — 1m24s · store 2imxj3j9
12:36:10 vestigia mul/aarch64-linux/diff/a72 — 1m43s · store 7l6hmbg3
12:37:53 vestigia mul/aarch64-linux/taint — 1m56s · store vh7r36hp
12:39:49 vestigia mul/x86_64-linux/diff/zen3 — 50s · store 8s4y2zdf
12:40:39 vestigia mul/x86_64-linux/taint — 52s · store raki077p
12:41:31 vestigia mul_wnaf/aarch64-linux/diff/a72 — 1m34s · store m5q4img3
12:43:05 vestigia mul_wnaf/aarch64-linux/taint — 1m56s · store h8akafqd
12:45:01 vestigia mul_wnaf/x86_64-linux/diff/zen3 — 53s · store 3bv8aqkp
12:45:54 vestigia mul_wnaf/x86_64-linux/taint — 52s · store df73nmlb
12:46:46 vestigia sign_ecdsa/aarch64-linux/diff/a72 — 2m14s · store qj5zxhh4
12:49:00 vestigia sign_ecdsa/aarch64-linux/taint — 2m31s · store nr5y5qxs
12:51:31 vestigia sign_ecdsa/x86_64-linux/diff/zen3 — 1m · store qz3id55f
12:52:31 vestigia sign_ecdsa/x86_64-linux/taint — 1m12s · store xbdx5q6n
12:53:43 vestigia sign_ecdsa_ctx/aarch64-linux/diff/a72 — 2m6s · store 6cr86sp1
12:55:49 vestigia sign_ecdsa_ctx/aarch64-linux/taint — 2m34s · store 6dwb3s0n
12:58:23 vestigia sign_ecdsa_ctx/x86_64-linux/diff/zen3 — 1m · store 4a1szzl1
12:59:23 vestigia sign_ecdsa_ctx/x86_64-linux/taint — 1m9s · store 801iwac4
13:00:32 vestigia sign_schnorr/aarch64-linux/diff/a72 — 2m24s · store dwb8i17k
13:02:56 vestigia sign_schnorr/aarch64-linux/taint — 2m19s · store y1rps5ws
13:05:15 vestigia sign_schnorr/x86_64-linux/diff/zen3 — 1m3s · store d8vmg0d4
13:06:18 vestigia sign_schnorr/x86_64-linux/taint — 1m · store 45zdcm4g
13:07:18 vestigia sign_schnorr_ctx/aarch64-linux/diff/a72 — 2m6s · store rja9x1i4
13:09:24 vestigia sign_schnorr_ctx/aarch64-linux/taint — 2m22s · store 4bhvm3hk
13:11:46 vestigia sign_schnorr_ctx/x86_64-linux/diff/zen3 — 1m4s · store zwmpb00h
13:12:50 vestigia sign_schnorr_ctx/x86_64-linux/taint — 1m3s · store 06nm1lfk
13:13:53 censor secp256k1-secret-scalar-instructions/aarch64-linux/instructions — 15m9s · clear · sealed 0b7750263eaa
13:29:02 censor secp256k1-secret-scalar-instructions/x86_64-linux/instructions — 3m54s · clear · sealed f89e71291c70
13:32:57 vestigia derive_pub/aarch64-linux/diff/a72 — 5s · store vkm4msr9
13:33:02 vestigia derive_pub/aarch64-linux/taint — 4s · store k10dbzxn
13:33:06 vestigia derive_pub/x86_64-linux/diff/zen3 — 4s · store fw93vgcy
13:33:10 vestigia derive_pub/x86_64-linux/taint — 4s · store n05jwpif
13:33:14 vestigia derive_pub_ctx/aarch64-linux/diff/a72 — 8s · store j4lyzqma
13:33:22 vestigia derive_pub_ctx/aarch64-linux/taint — 6s · store ihxmy2mg
13:33:28 vestigia derive_pub_ctx/x86_64-linux/diff/zen3 — 6s · store 0x032rxb
13:33:34 vestigia derive_pub_ctx/x86_64-linux/taint — 5s · store h07r536v
13:33:39 vestigia ecdh/aarch64-linux/diff/a72 — 4s · store hm0hhck8
13:33:43 vestigia ecdh/aarch64-linux/taint — 5s · store zji18jha
13:33:48 vestigia ecdh/x86_64-linux/diff/zen3 — 5s · store 2bjmdmdk
13:33:53 vestigia ecdh/x86_64-linux/taint — 7s · store 2imxj3j9
13:34:00 vestigia mul/aarch64-linux/diff/a72 — 4s · store 7l6hmbg3
13:34:04 vestigia mul/aarch64-linux/taint — 4s · store vh7r36hp
13:34:08 vestigia mul/x86_64-linux/diff/zen3 — 4s · store 8s4y2zdf
13:34:12 vestigia mul/x86_64-linux/taint — 4s · store raki077p
13:34:16 vestigia mul_wnaf/aarch64-linux/diff/a72 — 4s · store m5q4img3
13:34:20 vestigia mul_wnaf/aarch64-linux/taint — 5s · store h8akafqd
13:34:25 vestigia mul_wnaf/x86_64-linux/diff/zen3 — 4s · store 3bv8aqkp
13:34:29 vestigia mul_wnaf/x86_64-linux/taint — 4s · store df73nmlb
13:34:33 vestigia sign_ecdsa/aarch64-linux/diff/a72 — 4s · store qj5zxhh4
13:34:37 vestigia sign_ecdsa/aarch64-linux/taint — 4s · store nr5y5qxs
13:34:41 vestigia sign_ecdsa/x86_64-linux/diff/zen3 — 4s · store qz3id55f
13:34:45 vestigia sign_ecdsa/x86_64-linux/taint — 4s · store xbdx5q6n
13:34:49 vestigia sign_ecdsa_ctx/aarch64-linux/diff/a72 — 4s · store 6cr86sp1
13:34:53 vestigia sign_ecdsa_ctx/aarch64-linux/taint — 4s · store 6dwb3s0n
13:34:57 vestigia sign_ecdsa_ctx/x86_64-linux/diff/zen3 — 4s · store 4a1szzl1
13:35:01 vestigia sign_ecdsa_ctx/x86_64-linux/taint — 4s · store 801iwac4
13:35:05 vestigia sign_schnorr/aarch64-linux/diff/a72 — 4s · store dwb8i17k
13:35:09 vestigia sign_schnorr/aarch64-linux/taint — 4s · store y1rps5ws
13:35:13 vestigia sign_schnorr/x86_64-linux/diff/zen3 — 4s · store d8vmg0d4
13:35:17 vestigia sign_schnorr/x86_64-linux/taint — 4s · store 45zdcm4g
13:35:21 vestigia sign_schnorr_ctx/aarch64-linux/diff/a72 — 5s · store rja9x1i4
13:35:26 vestigia sign_schnorr_ctx/aarch64-linux/taint — 5s · store 4bhvm3hk
13:35:31 vestigia sign_schnorr_ctx/x86_64-linux/diff/zen3 — 4s · store zwmpb00h
13:35:35 vestigia sign_schnorr_ctx/x86_64-linux/taint — 6s · store 06nm1lfk
13:35:42 decisions 18 decisions signed · ledger 716e15d3337e
13:35:43 gate pass — 0 sites · 0 violations
13:35:44 bundle gate pass — 0 sites · 0 violations