Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use shake256 as Keccak without casting #55

Closed
sublimator opened this issue May 3, 2023 · 7 comments
Closed

Can't use shake256 as Keccak without casting #55

sublimator opened this issue May 3, 2023 · 7 comments
Labels
bug Something isn't working

Comments

@sublimator
Copy link

import { Keccak, shake256 } from '@noble/hashes/sha3'

import { PrngFn } from './types'

export function shakePrng(seed: Uint8Array): PrngFn {
  const prng = shake256.create({}) as Keccak
  prng.update(seed)
  return prng.xof.bind(prng)
}

Also a bit strange requiring empty object for the options

@paulmillr paulmillr added the bug Something isn't working label May 3, 2023
@paulmillr
Copy link
Owner

yeah

also you should probably be using:

import {keccakprg} from '@noble/hashes/sha3-addons';

@paulmillr
Copy link
Owner

For shakes, dkLen is usually needed.

@sublimator
Copy link
Author

sublimator commented May 4, 2023 via email

@sublimator
Copy link
Author

sublimator commented May 4, 2023

Ok, so I can't use keccakprg (for this particular purpose anyway) because the KeccakPRG class overrides the finish() method to be a noop, so while I could tinker with the suffix/outputLen post construction(capacity=510) (they are public members) they wouldn't be used anyway.

Was recreating this functionality here:
https://github.com/privacypass/challenge-bypass-server/blob/605bfa137c7ef8b3fc2bc94aceb9c77f593079bf/crypto/batch.go#L81C10-L98

@paulmillr
Copy link
Owner

Yeah, if you're trying to copy something, makes sense to not use prg.

BTW, keccakprg is official PRG from Keccak team.

@sublimator
Copy link
Author

// https://keccak.team/files/CSF-0.1.pdf
// + https://github.com/XKCP/XKCP/tree/master/lib/high/Keccak/PRG

BTW, keccakprg is official PRG from Keccak team.

Yeah! :)

I'm starting to realize the old version of PP was very prototypical with very strange nesting of base64 encoded json structures.

@paulmillr
Copy link
Owner

7c33eae

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants