Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sdk/compiler/daml-lf-ast/src/DA/Daml/LF/Ast/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ data BuiltinExpr

| BESecp256k1Bool -- :: Text -> Text -> Text -> Bool
| BESecp256k1WithEcdsaBool -- :: Text -> Text -> Text -> Bool
| BESecp256k1ValidateKey -- :: Text -> Bool

-- BigNumeric operations
| BEScaleBigNumeric -- :: BigNumeric -> Int64
Expand Down
1 change: 1 addition & 0 deletions sdk/compiler/daml-lf-ast/src/DA/Daml/LF/Ast/Pretty.hs
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ instance Pretty BuiltinExpr where
BEDecodeHex -> "HEX_TO_TEXT"
BESecp256k1Bool -> "SECP256K1_BOOL"
BESecp256k1WithEcdsaBool -> "SECP256K1_WITH_ECDSA_BOOL"
BESecp256k1ValidateKey -> "SECP256K1_VALIDATE_KEY"
BETrace -> "TRACE"
BETextToParty -> "TEXT_TO_PARTY"
BETextToInt64 -> "TEXT_TO_INT64"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ decodeBuiltinFunction = \case
LF2.BuiltinFunctionKECCAK256_TEXT -> pure BEKecCak256Text
LF2.BuiltinFunctionSECP256K1_BOOL -> pure BESecp256k1Bool
LF2.BuiltinFunctionSECP256K1_WITH_ECDSA_BOOL -> pure BESecp256k1WithEcdsaBool
LF2.BuiltinFunctionSECP256K1_VALIDATE_KEY -> pure BESecp256k1ValidateKey
LF2.BuiltinFunctionHEX_TO_TEXT -> pure BEDecodeHex
LF2.BuiltinFunctionTEXT_TO_HEX -> pure BEEncodeHex

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@ encodeBuiltinExpr = \case
BEDecodeHex -> builtin P.BuiltinFunctionHEX_TO_TEXT
BESecp256k1Bool -> builtin P.BuiltinFunctionSECP256K1_BOOL
BESecp256k1WithEcdsaBool -> builtin P.BuiltinFunctionSECP256K1_WITH_ECDSA_BOOL
BESecp256k1ValidateKey -> builtin P.BuiltinFunctionSECP256K1_VALIDATE_KEY

BEError -> builtin P.BuiltinFunctionERROR
BEAnyExceptionMessage -> builtin P.BuiltinFunctionANY_EXCEPTION_MESSAGE
Expand Down
1 change: 1 addition & 0 deletions sdk/compiler/daml-lf-tools/src/DA/Daml/LF/Simplifier.hs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ safetyStep = \case
BEDecodeHex -> Safe 0
BESecp256k1Bool -> Safe 0
BESecp256k1WithEcdsaBool -> Safe 0
BESecp256k1ValidateKey -> Safe 0
BEAppendText -> Safe 2
BETimestampToUnixMicroseconds -> Safe 1
BEUnixMicrosecondsToTimestamp -> Safe 0 -- can fail if the int represents an out-of-bounds date
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ typeOfBuiltin = \case
BEDecodeHex -> pure $ TText :-> TText
BESecp256k1Bool -> pure $ TText :-> TText :-> TText :-> TBool
BESecp256k1WithEcdsaBool -> pure $ TText :-> TText :-> TText :-> TBool
BESecp256k1ValidateKey -> pure $ TText :-> TBool
BEFoldl -> pure $ TForall (alpha, KStar) $ TForall (beta, KStar) $
(tBeta :-> tAlpha :-> tBeta) :-> tBeta :-> TList tAlpha :-> tBeta
BEFoldr -> pure $ TForall (alpha, KStar) $ TForall (beta, KStar) $
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ convertPrim _ "BESecp256k1Bool" (TText :-> TText :-> TText :-> TBool) =
pure $ EBuiltinFun BESecp256k1Bool
convertPrim _ "BESecp256k1WithEcdsaBool" (TText :-> TText :-> TText :-> TBool) =
pure $ EBuiltinFun BESecp256k1WithEcdsaBool
convertPrim _ "BESecp256k1ValidateKey" (TText :-> TBool) =
pure $ EBuiltinFun BESecp256k1ValidateKey

-- Integer arithmetic
convertPrim _ "BEAddInt64" (TInt64 :-> TInt64 :-> TInt64) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1784,6 +1784,7 @@ private[lf] object DecodeV2 {
BuiltinFunctionInfo(KECCAK256_TEXT, BKECCAK256Text),
BuiltinFunctionInfo(SECP256K1_BOOL, BSECP256K1Bool),
BuiltinFunctionInfo(SECP256K1_WITH_ECDSA_BOOL, BSECP256K1WithEcdsaBool),
BuiltinFunctionInfo(SECP256K1_VALIDATE_KEY, BSECP256K1ValidateKey),
BuiltinFunctionInfo(HEX_TO_TEXT, BDecodeHex),
BuiltinFunctionInfo(TEXT_TO_HEX, BEncodeHex),
BuiltinFunctionInfo(DATE_TO_UNIX_DAYS, BDateToUnixDays),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,8 @@ enum BuiltinFunction {
BIGNUMERIC_TO_TEXT = 2010; // *Available in versions >= 2.dev*

TYPE_REP_TYCON_NAME = 3011; // *Available in versions >= 2.dev*

SECP256K1_VALIDATE_KEY = 4001; // *Available in versions >= 2.dev*
Copy link
Contributor Author

@carlpulley-da carlpulley-da Nov 26, 2025

Choose a reason for hiding this comment

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

For the moment, SECP256K1_VALIDATE_KEY is dev only. A follow on PR will add damlc feature flags for this.

}

// Builtin literals
Expand Down
2 changes: 2 additions & 0 deletions sdk/daml-lf/encoder/src/test/lf/Builtin_2.dev_.lf
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ module BuiltinMod {
SECP256K1_BOOL;
val secp256k1WithEcdsaBool: Text -> Text -> Text -> Bool =
SECP256K1_WITH_ECDSA_BOOL;
val secp256k1ValidateKey: Text -> Bool =
SECP256K1_VALIDATE_KEY;
val textToHex: Text -> Text = TEXT_TO_HEX;
val hexToText: Text -> Text = HEX_TO_TEXT;
val dateToUnixDays: Date -> Int64 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ abstract class CostModel {
val BKECCAK256Text: CostFunction1[Text]
val BSECP256K1Bool: CostFunction3[Text, Text, Text]
val BSECP256K1WithEcdsaBool: CostFunction3[Text, Text, Text]
val BSECP256K1ValidateKey: CostFunction1[Text]
val BDecodeHex: CostFunction1[Text]
val BEncodeHex: CostFunction1[Text]
val BDateToUnixDays: CostFunction1[Date]
Expand Down Expand Up @@ -272,6 +273,7 @@ object CostModel {
override val BKECCAK256Text: CostFunction1[Text] = CostFunction1.Null
override val BSECP256K1Bool: CostFunction3[Text, Text, Text] = CostFunction3.Null
override val BSECP256K1WithEcdsaBool: CostFunction3[Text, Text, Text] = CostFunction3.Null
override val BSECP256K1ValidateKey: CostFunction1[Text] = CostFunction1.Null
override val BDecodeHex: CostFunction1[Text] = CostFunction1.Null
override val BEncodeHex: CostFunction1[Text] = CostFunction1.Null
override val BDateToUnixDays: CostFunction1[Date] = CostFunction1.Null
Expand Down Expand Up @@ -855,6 +857,8 @@ object CostModel {
CostFunction3.Constant(SBoolSize)
override val BSECP256K1WithEcdsaBool: CostFunction3[Text, Text, Text] =
CostFunction3.Constant(SBoolSize)
override val BSECP256K1ValidateKey: CostFunction1[Text] =
CostFunction1.Constant(SBoolSize)
override val BDecodeHex: CostFunction1[Text] = {
val poly = LinearPolynomial(STextWrapperSize + StringSize.a, StringSize.b / 2)
(t: String) => poly.calculate(t.length)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ private[lf] final class PhaseOne(
case BGreaterEq => SBGreaterEq
case BSECP256K1Bool => SBSECP256K1Bool
case BSECP256K1WithEcdsaBool => SBSECP256K1WithEcdsaBool
case BSECP256K1ValidateKey => SBSECP256K1ValidateKey

// TextMap

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@ object Ast {
final case object BSECP256K1Bool extends BuiltinFunction // : Text -> Text -> Text -> Bool
final case object BSECP256K1WithEcdsaBool
extends BuiltinFunction // : Text -> Text -> Text -> Bool
final case object BSECP256K1ValidateKey extends BuiltinFunction // : Text -> Bool

final case object BCoerceContractId
extends BuiltinFunction // : ∀a b. ContractId a -> ContractId b
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ private[parser] class ExprParser[P](parserParameters: ParserParameters[P]) {
"GREATER_EQ" -> BGreaterEq,
"SECP256K1_BOOL" -> BSECP256K1Bool,
"SECP256K1_WITH_ECDSA_BOOL" -> BSECP256K1WithEcdsaBool,
"SECP256K1_VALIDATE_KEY" -> BSECP256K1ValidateKey,
"COERCE_CONTRACT_ID" -> BCoerceContractId,
"ANY_EXCEPTION_MESSAGE" -> BAnyExceptionMessage,
"SCALE_BIGNUMERIC" -> BScaleBigNumeric,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ private[validation] object Typing {
BGreaterEq -> tComparison,
BSECP256K1Bool -> (TText ->: TText ->: TText ->: TBool),
BSECP256K1WithEcdsaBool -> (TText ->: TText ->: TText ->: TBool),
BSECP256K1ValidateKey -> (TText ->: TBool),
BCoerceContractId ->
TForall(
alpha.name -> KStar,
Expand Down