-
Notifications
You must be signed in to change notification settings - Fork 1
Feature/update contracts sdk with snickerdoodle wallet #1268
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
Open
seansing9
wants to merge
42
commits into
feature/new-contracts-package
Choose a base branch
from
feature/update-contracts-sdk-with-snickerdoodle-wallet
base: feature/new-contracts-package
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
6acef0d
WIP update snickerdoodlewallet in contracts sdk
seansing 16831ba
Merge branch 'feature/new-contracts-package' into feature/update-cont…
seansing e3ea980
Merge branch 'feature/new-contracts-package' into feature/update-cont…
seansing d37d18f
Merge branch 'feature/new-contracts-package' into feature/update-cont…
seansing 531b8a2
Merge branch 'feature/new-contracts-package' into feature/update-cont…
seansing c84f9e7
Merge branch 'feature/new-contracts-package' into feature/update-cont…
seansing 342ff40
complete contracts-sdk update for Snickerdoodle wallet and factory
seansing 08d3741
Merge branch 'feature/new-contracts-package' into feature/update-cont…
seansing9 b3aae7a
update objects
seansing9 1d9df85
WIP update contracts-sdk and crypto utils
seansing9 b448258
Merge branch 'feature/new-contracts-package' into feature/update-cont…
seansing9 3ff8ed2
update contracts-sdk
seansing9 713b88e
Merge branch 'feature/new-contracts-package' into feature/update-cont…
seansing9 5a361d5
updated signature components
seansing9 098ed88
updated cryptoutils, included unit test
seansing9 fc37861
update function name
seansing9 0269fee
clean up
seansing9 fe478bc
fix from comments
seansing9 807ed06
fix from discussion
seansing9 3a17a16
rename AuthenticatorData to P256VerificationData
seansing9 66fcf4e
Fixed methods for generating challenges.
SnickerChar 93f2259
Publish node-utils
SnickerChar 0dc9e89
implement generate challenge
seansing9 3a2e049
Merge branch 'feature/new-contracts-package' into feature/update-cont…
seansing9 bf3f410
update contracts sdk with latest functions
seansing9 a68e54c
Merge branch 'feature/new-contracts-package' into feature/update-cont…
seansing9 a283e3d
Change challenge methods to static
SnickerChar 5dc0003
update generate challenge functions, add @hexagon/base64, add unit test
seansing9 1e9b311
update version, fix interface
seansing9 80f754e
normalize evm address before generating challenge
seansing9 ab4fafe
Added contract addresses to chain information.
SnickerChar 7a330e8
Change ChainInformation because the idea of different info only for t…
SnickerChar 9d4b85f
Removed unnecessary msgPayload parameter from parseRawP256Signature
SnickerChar 2ab2efa
Merge branch 'feature/new-contracts-package' into feature/update-cont…
seansing9 3a3efab
updated contracts sdk functions and abi
seansing9 dcc50ec
include operator gateway proxy deployment, updated dockerfiles, remov…
seansing9 d0495ac
merged feature/new-contracts-package
seansing9 3189707
updated addresses in chains config, add scripts to contracts-sdk pack…
seansing9 39a3817
Fix non-export of BlockchainErrorMapper
SnickerChar c8feeec
Merge branch 'feature/update-contracts-sdk-with-snickerdoodle-wallet'…
SnickerChar 3322b8e
update contracts sdk
seansing9 76d8b87
add asn1 prefix to parsing p256 public key
seansing9 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| import { base64 } from "@hexagon/base64"; | ||
| import { | ||
| EVMAccountAddress, | ||
| EVMContractAddress, | ||
|
|
@@ -14,7 +15,7 @@ import { | |
| } from "@snickerdoodlelabs/objects"; | ||
| import { ethers } from "ethers"; | ||
| import { injectable } from "inversify"; | ||
| import { ok, Result, ResultAsync } from "neverthrow"; | ||
| import { err, ok, Result, ResultAsync } from "neverthrow"; | ||
|
|
||
| import { BaseContract } from "@contracts-sdk/implementations/BaseContract.js"; | ||
| import { IEthersContractError } from "@contracts-sdk/implementations/BlockchainErrorMapper.js"; | ||
|
|
@@ -99,8 +100,37 @@ export class SnickerdoodleWalletContract | |
| public generateAddP256KeyWithP256KeyChallenge( | ||
| newKeyId: WebauthnCredentialId, | ||
| newP256PublicKey: P256PublicKeyComponents, | ||
| ): Result<string, InvalidParametersError> { | ||
| return ok(newKeyId + newP256PublicKey.x + newP256PublicKey.y); | ||
| ): Result<Uint8Array, InvalidParametersError> { | ||
| // Convert keyid to Uint8Array (UTF-8 encoding) | ||
| const uint8keyId = new TextEncoder().encode(newKeyId); | ||
|
|
||
| // Convert qx and qy from hex string to Uint8Array | ||
| const uint8qx = new Uint8Array( | ||
| newP256PublicKey.x | ||
| .slice(2) | ||
| .match(/.{1,2}/g) | ||
| ?.map((byte) => parseInt(byte, 16)) ?? [], | ||
| ); | ||
| const uint8qy = new Uint8Array( | ||
| newP256PublicKey.y | ||
| .slice(2) | ||
| .match(/.{1,2}/g) | ||
| ?.map((byte) => parseInt(byte, 16)) ?? [], | ||
| ); | ||
|
|
||
| if (uint8qx.length == 0 || uint8qy.length == 0) { | ||
| return err(new InvalidParametersError("Invalid P256PublicKeyComponents")); | ||
| } | ||
|
|
||
| // Combine all Uint8Arrays into a single Uint8Array | ||
| const totalLength = uint8keyId.length + uint8qx.length + uint8qy.length; | ||
| const payload = new Uint8Array(totalLength); | ||
|
|
||
| payload.set(uint8keyId, 0); | ||
| payload.set(uint8qx, uint8keyId.length); | ||
| payload.set(uint8qy, uint8keyId.length + uint8qx.length); | ||
|
|
||
| return ok(payload); | ||
| } | ||
|
|
||
| public addEVMAddressWithP256Key( | ||
|
|
@@ -132,8 +162,9 @@ export class SnickerdoodleWalletContract | |
|
|
||
| public generateAddEVMAddressWithP256KeyChallenge( | ||
| evmAccountAddress: EVMAccountAddress, | ||
| ): Result<string, InvalidParametersError> { | ||
| return ok(evmAccountAddress); | ||
| ): Result<Uint8Array, InvalidParametersError> { | ||
| // Remove 0x, convert to Uint8Array | ||
| return ok(new TextEncoder().encode(evmAccountAddress.slice(2))); | ||
| } | ||
|
|
||
| public addEVMAccountWithEVMAccount( | ||
|
|
@@ -281,4 +312,11 @@ export class SnickerdoodleWalletContract | |
| ): SnickerdoodleWalletContractError { | ||
| return new SnickerdoodleWalletContractError(msg, e, transaction); | ||
| } | ||
|
|
||
| private isoBase64fromBuffer( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This method isn't needed now, should remove it, along with the import |
||
| buffer: Uint8Array, | ||
| to: "base64" | "base64url" = "base64url", | ||
| ): string { | ||
| return base64.fromArrayBuffer(buffer, to === "base64url"); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should check this out, and make sure it works with both 0x123 and just 123. I think that .encode will handle both versions, you should test that.