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

[stacks-signer] Public Keys Don't Match - Signer Not Registered #4761

Open
BowTiedDevOps opened this issue May 8, 2024 · 1 comment · Fixed by #4762
Open

[stacks-signer] Public Keys Don't Match - Signer Not Registered #4761

BowTiedDevOps opened this issue May 8, 2024 · 1 comment · Fixed by #4762

Comments

@BowTiedDevOps
Copy link
Collaborator

BowTiedDevOps commented May 8, 2024

The public keys generated by generate-stacking-signature and check-config don't match. I've used the public key generated by stacking signature command in stack-aggregation-commit contract calls and the signer is not registered for cycle 84. The private/public keys are generated directly off secp256k1 package in node:

const EC = require("elliptic").ec;
const secp256k1 = new EC("secp256k1");
const enc = require("@stacks/encryption");
const process = require("process");
const key = secp256k1.genKeyPair();

while (true) {
  const key_hex = key.getPrivate().toString("hex");
  if (key_hex.length != 64) {
    continue;
  }
  break;
}
try {
  const privateKey = key.getPrivate().toString("hex");
  const publicKey = enc.getPublicKeyFromPrivate(privateKey);
  process.stdout.write([publicKey, ":", privateKey].join(""));
} catch {
  return process.exit(1);
}
return process.exit(0);

generate-stacking-signature response:

$ ./stacks-signer generate-stacking-signature --pox-address <> --reward-cycle 84 --config ./signer.toml --method agg-commit --period 1 --max-amount 500000000000 --auth-id 0

Signer Public Key: 0x0303144ba518fe7a0fb56a8a7d488f950307a4330f146e1e1458fc63fb33defe96
Signer Key Signature: <>

check-config response:

$ ./stacks-signer check-config --config signer.toml 
Config: 
Stacks node host: 127.0.0.1:30443
Signer endpoint: 0.0.0.0:30000
Stacks address: SPYQ2Q584Y5059SEVN695YREBZ3RPJ68GJBQTPV8
Public key: 0403144ba518fe7a0fb56a8a7d488f950307a4330f146e1e1458fc63fb33defe96193e4d30f75dc540cc29c27de85a0233bd084628d430add9c2229cdebe55a997
Network: mainnet
Database path: /stacks-blockchain/signer/signer.sqlite
DKG transaction fee: 0.01 uSTX

Using stx get_address <privKey>, @stacks/transactions package and check-config all point to the address SPYQ2Q584Y5059SEVN695YREBZ3RPJ68GJBQTPV8, while the public key generated from generate-stacking-signature matches the address SP2H1N2V9S7PEBC0120S3WMEAT32B9N7CGMPSGF16 (checked by @hstove).

On another note, the public key generated by generate-stacking-signature is the same one that is being generated in the node script (process.stdout.write([publicKey, ":", privateKey].join(""));).

I haven't seen other signers run into this issue, so that makes me think if it's because of the way the private key is being generated.

@BowTiedDevOps
Copy link
Collaborator Author

Update:
After trying with Hank's implementation of compressed key in the check-config function (#4762), the public keys match, but the signer is still unregistered:

$ ./stacks-signer-fix-signer-pk-hex generate-stacking-signature -p bc1p8vg588hldsnv4a558apet4e9ff3pr4awhqj2hy8gy6x2yxzjpmqsvvpta4 -r 22 --method stack-stx --max-amount 340282366920938463463374607431768211455 --auth-id 1 --period 10 --config signer.toml
Signer Public Key: 0x0303144ba518fe7a0fb56a8a7d488f950307a4330f146e1e1458fc63fb33defe96
Signer Key Signature: 0xd47d49ef4eed1917c3d4d5d1df2f0069b65f88c59b760b1fe26043630956885549b192e78af4c0526468b3872fb1838d4c6cf697f5eb626ef8eefdde28f4343700


$ ./stacks-signer-fix-signer-pk-hex check-config --config signer.toml 
Config: 
Stacks node host: 127.0.0.1:30443
Signer endpoint: 0.0.0.0:30000
Stacks address: SPYQ2Q584Y5059SEVN695YREBZ3RPJ68GJBQTPV8
Public key: 0303144ba518fe7a0fb56a8a7d488f950307a4330f146e1e1458fc63fb33defe96
Network: mainnet
Database path: /stacks-blockchain/signer/signer.sqlite
DKG transaction fee: 0.01 uSTX
Metrics endpoint: None

The link to the stack-aggregate-commit transaction, which is made with the same signer key as the one shared above:

@hstove hstove linked a pull request May 8, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Status: 🆕 New
Development

Successfully merging a pull request may close this issue.

1 participant