Skip to content

Conversation

@carlpulley-da
Copy link
Contributor

@carlpulley-da carlpulley-da commented Nov 26, 2025

  • expose SECP256K1_VALIDATE_KEY primitive to Daml
  • introduce secp2561WithValidation and validatePublicKey Daml functions
  • daml-script testing of new Daml functions
@carlpulley-da carlpulley-da self-assigned this Nov 26, 2025
@carlpulley-da carlpulley-da changed the base branch from main to cjp/issue-29484-wiring November 26, 2025 18:26
-- All rights reserved.

-- @SINCE-LF 2.dev
-- @SINCE-LF 2.1
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm observing secp256k1WithEcdsaOnly in daml_2.1.lf, so figure this should always have been since 2.1?

where
signatory owner
ensure secp256k1 signature (keccak256 (serialize burnMessage)) publicKey
ensure secp256k1WithEcdsaOnly signature (keccak256 (serialize burnMessage)) publicKey
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bug fix

testKeyPairSignature <- secp256k1sign testKeyPair.privateKey expectedDigest
(secp256k1 testKeyPairSignature expectedDigest testKeyPair.publicKey === True)
actualSignatureWithEcdsaAndSha256 <- secp256k1signWithEcdsaOnly testKeyPair.privateKey (sha256 expectedDigest)
(secp256k1 actualSignatureWithEcdsaAndSha256 expectedDigest testKeyPair.publicKey === True)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bug fixes

actualSignatureWithEcdsaAndSha256 <- secp256k1signWithEcdsaOnly privateKey1 (sha256 expectedDigest)
actualSignature <- secp256k1sign privateKey1 expectedDigest
(actualSignatureWithEcdsaAndSha256 === actualSignature)
actualSignature <- secp256k1signWithEcdsaOnly privateKey1 expectedDigest
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Simplification

@carlpulley-da carlpulley-da marked this pull request as ready for review November 26, 2025 18:34
@carlpulley-da carlpulley-da requested a review from a team November 26, 2025 18:34
Copy link
Collaborator

@remyhaemmerle-da remyhaemmerle-da left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines +101 to +102
| not (isDEREncoded pk) = error $ "Public key argument is not a DER encoded hex string: " <> pk
| otherwise = primitive @"BESecp256k1ValidateKey" (Text.asciiToLower pk)
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 we should do the validation and lower case translation in scala directly, to avoid excessive in cost in gaz.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants