Skip to content

Commit

Permalink
Reduce number of AES calls needed by using the LSB of s for t in Idpf…
Browse files Browse the repository at this point in the history
…Poplar.extend (#303)
  • Loading branch information
schoppmp authored Oct 25, 2023
1 parent 1d960b2 commit 9426729
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
12 changes: 8 additions & 4 deletions draft-irtf-cfrg-vdaf.md
Original file line number Diff line number Diff line change
Expand Up @@ -4313,11 +4313,15 @@ def eval_next(IdpfPoplar, prev_seed, prev_ctrl,
def extend(IdpfPoplar, seed, binder):
xof = XofFixedKeyAes128(seed, format_dst(1, 0, 0), binder)
s = [
xof.next(XofFixedKeyAes128.SEED_SIZE),
xof.next(XofFixedKeyAes128.SEED_SIZE),
bytearray(xof.next(XofFixedKeyAes128.SEED_SIZE)),
bytearray(xof.next(XofFixedKeyAes128.SEED_SIZE)),
]
b = xof.next(1)[0]
t = [Field2(b & 1), Field2((b >> 1) & 1)]
# Use the least significant bits as the control bit correction,
# and then zero it out. This gives effectively 127 bits of
# security, but reduces the number of AES calls needed by 1/3.
t = [Field2(s[0][0] & 1), Field2(s[1][0] & 1)]
s[0][0] &= 0xFE
s[1][0] &= 0xFE
return (s, t)

def convert(IdpfPoplar, level, seed, binder):
Expand Down
12 changes: 8 additions & 4 deletions poc/idpf_poplar.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,15 @@ def eval_next(IdpfPoplar, prev_seed, prev_ctrl,
def extend(IdpfPoplar, seed, binder):
xof = XofFixedKeyAes128(seed, format_dst(1, 0, 0), binder)
s = [
xof.next(XofFixedKeyAes128.SEED_SIZE),
xof.next(XofFixedKeyAes128.SEED_SIZE),
bytearray(xof.next(XofFixedKeyAes128.SEED_SIZE)),
bytearray(xof.next(XofFixedKeyAes128.SEED_SIZE)),
]
b = xof.next(1)[0]
t = [Field2(b & 1), Field2((b >> 1) & 1)]
# Use the least significant bits as the control bit correction,
# and then zero it out. This gives effectively 127 bits of
# security, but reduces the number of AES calls needed by 1/3.
t = [Field2(s[0][0] & 1), Field2(s[1][0] & 1)]
s[0][0] &= 0xFE
s[1][0] &= 0xFE
return (s, t)

@classmethod
Expand Down

0 comments on commit 9426729

Please sign in to comment.