Skip to content

Conversation

@sakethkotamraju
Copy link

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

- domain verification key generation script for well known file
- yarn generate-key-script
- readme doc on how to use it
Copy link
Collaborator

@montycheese montycheese left a comment

Choose a reason for hiding this comment

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

left some comments

Comment on lines 19 to 21
const cwdArgIndex = process.argv.indexOf('--cwd');
if (cwdArgIndex !== -1 && process.argv[cwdArgIndex + 1]) {
return process.argv[cwdArgIndex + 1];
Copy link
Collaborator

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',
Copy link
Collaborator

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');
Copy link
Collaborator

Choose a reason for hiding this comment

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

Base

Comment on lines 69 to 70
const wellKnownDir = join(outputDir, '.well-known');
mkdirSync(wellKnownDir, { recursive: true });
Copy link
Collaborator

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'
Copy link
Collaborator

@montycheese montycheese left a 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');
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
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);
Copy link
Collaborator

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?

@@ -0,0 +1,68 @@
const crypto = require('crypto');
Copy link
Collaborator

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
Copy link
Collaborator

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.
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