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

raw token converters #207

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open

raw token converters #207

wants to merge 1 commit into from

Conversation

gandlafbtc
Copy link
Collaborator

Fixes: exposing functions for raw token format

Description

Some transport methods (like nfc) require the lowest amount of data overhead possible. This PR addresses that by externalizing the raw token format (CBOR)

Changes

  • Extracted template converter functions
  • added utility function to convert token to and from raw format
  • expose utility functions on index.ts

PR Tasks

  • Open PR
  • run npm run test --> no failing unit tests
  • run npm run format

Copy link
Collaborator

@Egge21M Egge21M left a comment

Choose a reason for hiding this comment

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

Awesome! I don't think this is specced yet, is it? Blazingly fast! I dont mind getting ahead of the spec, however we need to keep an eye out for any changes.

@@ -521,3 +531,16 @@ export function hasValidDleq(proof: Proof, keyset: MintKeys): boolean {

return true;
}

export function tokenToRawToken(token: string | Token): Uint8Array {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This feels like bait :P
I think we should come up with a proper name for this. We call the the serialised version TokenV4 and the object notation TokenV4Template, so maybe this can be TokenV4Binary?

@@ -521,3 +531,16 @@ export function hasValidDleq(proof: Proof, keyset: MintKeys): boolean {

return true;
}

export function tokenToRawToken(token: string | Token): Uint8Array {
if (typeof token === 'string') {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would prefer this to only accept token and outsource conversion to the implementer. I think the readability improves if functions only do one (or close to one) thing.

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.

2 participants