Skip to content

Conversation

@lonerapier
Copy link
Collaborator

@lonerapier lonerapier commented Oct 30, 2025

Changes needed to test this repository with MFKDF reference implementation.

Other PR/packages

Changes

  • differential-test feature flag
  • det_rng module for deterministic rng
    • replace OsRng with GlobalRng throughout factor construction, derived key features, shamir shares
  • real entropy from u32 -> f64
  • removed salt from MFDKF2Factor
  • hotp: create target before padded secret
  • integrity: sort policy factor params by key
  • PolicyFactor: skip field serialization if empty
  • ooba:
    • replace String params and keys to Value or concrete Jwk type
    • remove code from params, and add uppercase.
  • question: answer normalisation
  • Policy: deterministic id generation by hashing all factor ids
  • reconstitution: use BTreeMap instead of HashMap for ordered keys in factor, outputs
  • TS api facade: nested parsing and stringification.
    • Needed due to read and write to internal state of the key.

Note

  • ooba derived key is modified by hardcoding:
    • next param: can't be same because node's native rsa encrypt uses internal rng
    • ext: node's native Jwk struct adds ext for browser support. Not mentioned in RFC
    • hmac: can't be same due to above fields.
  • Skipping derived key output check for stack factor

Base automatically changed from complete-features to main November 3, 2025 16:19
@lonerapier lonerapier marked this pull request as ready for review November 4, 2025 11:19
return value;
}

function stringifyFactorParams(value: any): any {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: This can definitely be simplified a lot, maybe removed altogether.

stringification is needed due to nested parsing done in differential test. the derived key similarity validation reads the internal state of the key.

Comment on lines +9 to +11
thread_local! {
static RNG: RefCell<ChaCha20Rng> = RefCell::new(ChaCha20Rng::from_seed(DEFAULT_SEED));
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is cursed rust.

Can you use a OnceCell or whatever here to create a static?

This clearly works but I've never seen it done this way.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OnceCell can't work due to no mutable reference in static.
Other options would be a lazylock, but that would require a mutex. I used this to prevent any locks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really? I see.

The thread_local! is also bizarre.

Anyway, not a big deal especially if it works because this is really just for differential testing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Autoparallel
Copy link
Contributor

Let me go review the related PRs

], { id: 'key1' })
const setup2Clone = JSON.parse(JSON.stringify(setup2))

// purposely modify the setup2Clone to make it similar to the setup
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooba derived key is modified by hardcoding:

  • next param: can't be same because node's native rsa encrypt uses internal rng
  • ext: node's native Jwk struct adds ext for browser support. Not mentioned in RFC
  • hmac: can't be same due to above fields.

@Autoparallel
Copy link
Contributor

This is looking good! Almost there. Resolved many comments. Left up relevant ones.

Let's get all of your documentation and the differential tests nicely displayed on the github pages so we can easily point to this for further security work.

Again, awesome job! <3

@lonerapier
Copy link
Collaborator Author

@Autoparallel this seems good to merge. I've opened another PR for mdbook and documentation detailing steps to setup, reproduce the bindings and differential testing.

* add mdbook

* publish book

* add roadmap and fix readme

* add toc, fix justfile commands
@lonerapier lonerapier merged commit 27ae6e8 into main Nov 12, 2025
10 checks passed
@lonerapier lonerapier deleted the differential-tests branch November 12, 2025 05:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants