-
Notifications
You must be signed in to change notification settings - Fork 12
[BA-2207] Adds script to generate jwks well known file & the private key #34
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
base: domain-verification
Are you sure you want to change the base?
Conversation
- domain verification key generation script for well known file - yarn generate-key-script - readme doc on how to use it
montycheese
left a comment
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.
left some comments
| const cwdArgIndex = process.argv.indexOf('--cwd'); | ||
| if (cwdArgIndex !== -1 && process.argv[cwdArgIndex + 1]) { | ||
| return process.argv[cwdArgIndex + 1]; |
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.
this isn't documented anywhere - but we likely don't need it anyways.
| x, | ||
| y, | ||
| use: 'sig', | ||
| kid: 'coinbase-domain-verification', |
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.
base
| try { | ||
| const outputDir = getOutputDir(); | ||
|
|
||
| console.log('🔑 Generating Coinbase domain verification keys...\n'); |
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.
Base
| const wellKnownDir = join(outputDir, '.well-known'); | ||
| mkdirSync(wellKnownDir, { recursive: true }); |
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.
I don't think we need to output it to a local directory called .well-known. also its currently but created as a hidden directory which might be annoying
- no .well-known output directory - changed 'Coinbase' to 'base'
montycheese
left a comment
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.
Lgtm. One small update. I'm going to pull locally to verify running locally before approving
|
|
||
| function main() { | ||
| try { | ||
| console.log('🔑 Generating Coinbase domain verification keys...\n'); |
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.
| console.log('🔑 Generating Coinbase domain verification keys...\n'); | |
| console.log('🔑 Generating Base domain verification keys...\n'); |
| function generateDomainVerificationKeys() { | ||
| // Generate a random private key | ||
| const privateKeyBytes = randomBytes(32); | ||
| const privateKey = base64url(privateKeyBytes); |
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.
Does this need to be in base 64?
verify-signature.js
Outdated
| @@ -0,0 +1,68 @@ | |||
| const crypto = require('crypto'); | |||
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.
move this to scripts/verify-domain-keys-test.js
| ``` | ||
|
|
||
| ## Output | ||
| - `.well-known/base-jwks.json`: Public key in JWKS format for domain verification |
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.
i think the output here is just base-jwk.json? cuz the file is generated in projectRoot/base-jek.json
- doesn't base64 encode the private key - yarn validate-key-script for testing sec256kp1 encoding/decoding.
Summary
https://linear.app/coinbase/issue/BA-2207/wsdk-create-script-to-generate-well-known-jwks-file-as-well-as-the
Generates the sec256k1 public key & outputs it in the base-jwks.json file. It also outputs the corresponding private key in the domain-verification-private-key.txt file. I also made a docs/domain-verification-key-generation readme file for instructions on how to do all of this.
How did you test your changes?
I ran the command and verified the generated output contents were accurate and outputted in the correct folder/file path.
Screen.Recording.2025-06-27.at.9.16.05.AM.mov