diff --git a/.github/workflows/slack-message-broker.yml b/.github/workflows/slack-message-broker.yml index f80be8d8185..9c5e647520f 100644 --- a/.github/workflows/slack-message-broker.yml +++ b/.github/workflows/slack-message-broker.yml @@ -26,38 +26,75 @@ jobs: - name: Prepare Slack Message uses: actions/github-script@main id: prepare-slack-message - if: > - (github.event_name == 'workflow_run' && !github.event.workflow_run.pull_requests[0].draft) || - (github.event_name == 'check_run' && !github.event.check_run.check_suite.pull_requests[0].draft) + with: script: | console.log(${{ toJson(github.event) }}); - function getSlackMemberToBeNotified() { + function getSlackMembersToBeNotified() { const senderLogin = "${{ github.event.sender.login }}"; + const workflowName = "${{ github.event.workflow.name }}"; + const slackMemberIds = { - "zeme-wana": "U03HGDNDRKR", - "effectfully": "UBH8K0ZU2", - "kwxm": "UCF4SL4BT", - "Unisay": "U02V796524S", - "ramsay-t": "U05T49F9FV1", - "ana-pantilie": "U05V2854W86", - "zliu41": "U03BP2HTKDK", - "bezirg": "UQ1LUSR8B", - "erikd": "U914V9D2B" + "zeme-wana": ["U03HGDNDRKR"], + "effectfully": ["UBH8K0ZU2"], + "kwxm": ["UCF4SL4BT"], + "Unisay": ["U02V796524S"], + "ramsay-t": ["U05T49F9FV1"], + "ana-pantilie": ["U05V2854W86"], + "zliu41": ["U03BP2HTKDK"], + "bezirg": ["UQ1LUSR8B"], + "erikd": ["U914V9D2B"] + }; + + const workflowOwners = { + "🗽 Cardano Constitution Tests": ["UQ1LUSR8B"], + "🩺 Longitudinal Benchmark": ["UBH8K0ZU2"], + "💰 Cost Model Benchmark": ["UBH8K0ZU2"], + "🌘 Nightly Testsuite": ["UQ1LUSR8B"] }; - if (senderLogin in slackMemberIds) { - return `<@${slackMemberIds[senderLogin]}>`; + + function at(ids) { + return ids.reduce((acc, id) => acc + `<@${id}> `, ""); + } + + if (workflowName in workflowOwners) { + return at(workflowOwners[workflowName]); + } else if (senderLogin in slackMemberIds) { + return at(slackMemberIds[senderLogin]); } else { - return "@{senderLogin}"; + return `@${senderLogin}`; } } + + const isWorkflowRunEvent = "${{ github.event_name }}" == "workflow_run"; + const isCheckRunEvent = "${{ github.event_name }}" == "check_run"; + + + function isDraftPullRequest() { + const workflowRunPrIsNull = "${{ github.event.workflow_run.pull_requests == null }}" === "true"; + const isDraftPrWorkflowRun = "${{ github.event.workflow_run.pull_requests[0][0].draft }}" === "true"; + + const checkRunPrIsNull = "${{ github.event.check_run.pull_requests == null }}" === "true"; + const isDraftPrCheckRun = "${{ github.event.check_run.pull_requests[0][0].draft }}" === "true"; + + console.log(`isWorkflowRunEvent: ${isWorkflowRunEvent}`); + console.log(`isCheckRunEvent: ${isCheckRunEvent}`); + console.log(`workflowRunPrIsNull: ${workflowRunPrIsNull}`); + console.log(`checkRunPrIsNull: ${checkRunPrIsNull}`); + console.log(`isDraftPrWorkflowRun: ${isDraftPrWorkflowRun}`); + console.log(`isDraftPrCheckRun: ${isDraftPrCheckRun}`); + + return isDraftPrWorkflowRun || isDraftPrCheckRun; + } + + const slackMembers = getSlackMembersToBeNotified(); + const isDraftPR = isDraftPullRequest(); - let message = ""; - let shouldSendMessage = false; - let slackMember = getSlackMemberToBeNotified(); + let message; + let shouldSendMessage; function handleWorkflowRunEvent() { @@ -68,10 +105,10 @@ jobs: const failureConclusions = [ "failure", "null", "action_required", "neutral", "timed_out" ]; if (failureConclusions.includes(conclusion)) { - message = `❌ ${name} \`${conclusion}\` <${url}|View Logs> ${slackMember}`; + message = `❌ ${name} \`${conclusion}\` <${url}|View Logs> ${slackMembers}`; shouldSendMessage = true; } else { - message = `${name} \`${status}\` \`${conclusion}\` <${url}|View Logs> ${slackMember}`; + message = `${name} \`${status}\` \`${conclusion}\` <${url}|View Logs> ${slackMembers}`; shouldSendMessage = false; } } @@ -91,21 +128,21 @@ jobs: ]; if (conclusion == "failure" && checkRunWatchlist.includes(name)) { - message = `❌ ${name} \`${conclusion}\` <${url}|View Logs> ${slackMember}`; + message = `❌ ${name} \`${conclusion}\` <${url}|View Logs> ${slackMembers}`; shouldSendMessage = true; } else { - message = `${name} \`${status}\` \`${conclusion}\` <${url}|View Logs> ${slackMember}`; + message = `${name} \`${status}\` \`${conclusion}\` <${url}|View Logs> ${slackMembers}`; shouldSendMessage = false; } } - if ("${{ github.event_name }}" == "workflow_run") { + if (!isDraftPR && isWorkflowRunEvent) { handleWorkflowRunEvent(); - } else if ("${{ github.event_name }}" == "check_run") { + } else if (!isDraftPR && isCheckRunEvent) { handleCheckRunEvent(); } else { - message = `Unknown event: ${{ github.event_name }}`; + message = `Unknown event or draft PR: ${{ github.event_name }}`; shouldSendMessage = true; } diff --git a/.github/workflows/sprint-issues-rollover.yml b/.github/workflows/sprint-issues-rollover.yml index a155da7b406..7e7971e252d 100644 --- a/.github/workflows/sprint-issues-rollover.yml +++ b/.github/workflows/sprint-issues-rollover.yml @@ -1,9 +1,10 @@ # This workflows moves issues and pull requests to the next sprint iteration of -# the Plutus Backlog project. In practice, all open backlog items in the Last -# iteration (the one that has just finished) the will be moved to the Current -# iteration (the one that has just started) +# the Plutus Backlog project. In practice, all open backlog items in the Current +# Iteration (the one that is still in progress) will be moved to the Next +# Iteration (the one that will start next). # This workflow must be run manually from the GitHub Actions page. -# Make sure that the Current iteration has started before running this workflow. +# In practice you want to run this on the last day of the current sprint, the +# day before the next sprint begins. name: "🛼 Sprint Issues Rollover" diff --git a/cardano-constitution/test/PlutusLedgerApi/V3/ArbitraryContexts.hs b/cardano-constitution/test/PlutusLedgerApi/V3/ArbitraryContexts.hs index 57aaa60e470..86718788f55 100644 --- a/cardano-constitution/test/PlutusLedgerApi/V3/ArbitraryContexts.hs +++ b/cardano-constitution/test/PlutusLedgerApi/V3/ArbitraryContexts.hs @@ -68,7 +68,7 @@ memptyTxInfo = TxInfo , txInfoReferenceInputs = mempty , txInfoOutputs = mempty , txInfoFee = zero - , txInfoMint = mempty + , txInfoMint = emptyMintValue , txInfoTxCerts = mempty , txInfoWdrl = AssocMap.unsafeFromList mempty , txInfoValidRange = always diff --git a/doc/docusaurus/package.json b/doc/docusaurus/package.json index 7a53d424f42..3ed33283528 100644 --- a/doc/docusaurus/package.json +++ b/doc/docusaurus/package.json @@ -15,23 +15,26 @@ "typecheck": "tsc" }, "dependencies": { + "http-proxy-middleware": "^2.0.7", + "mermaid": "^10.9.3", + "cookie": "^0.7.0", + "path-to-regexp": "^1.9.0", "@cmfcmf/docusaurus-search-local": "^1.1.0", "@docusaurus/core": "3.3.0", "@docusaurus/plugin-google-gtag": "3.3.0", "@docusaurus/preset-classic": "3.3.0", "@docusaurus/theme-mermaid": "3.3.0", "@mdx-js/react": "^3.0.0", - "body-parser": "1.20.3", + "body-parser": "^1.20.3", "clsx": "^2.0.0", - "express": "4.20.0", - "micromatch": "4.0.8", - "path-to-regexp": "3.3.0", + "express": "^4.20.0", + "micromatch": "^4.0.8", "prism-react-renderer": "^2.3.0", "react": "^18.0.0", "react-dom": "^18.0.0", - "send": "0.19.0", - "serve-static": "1.16.0", - "webpack": "5.94.0" + "send": "^0.19.0", + "serve-static": "^1.16.0", + "webpack": "^5.94.0" }, "devDependencies": { "@docusaurus/module-type-aliases": "3.2.1", diff --git a/doc/docusaurus/yarn.lock b/doc/docusaurus/yarn.lock index 2b3e5d79f59..8c65e5b9a32 100644 --- a/doc/docusaurus/yarn.lock +++ b/doc/docusaurus/yarn.lock @@ -2152,7 +2152,7 @@ dependencies: "@types/ms" "*" -"@types/eslint-scope@^3.7.3": +"@types/eslint-scope@^3.7.3", "@types/eslint-scope@^3.7.7": version "3.7.7" resolved "https://registry.yarnpkg.com/@types/eslint-scope/-/eslint-scope-3.7.7.tgz#3108bd5f18b0cdb277c867b3dd449c9ed7079ac5" integrity sha512-MzMFlSLBqNF2gcHWO0G1vP/YQyfvrxZ0bF+u7mzUdZ1/xK4A4sru+nraZz5i3iEIk1l1uyicaDVTB4QbbEkAYg== @@ -2180,6 +2180,11 @@ resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.5.tgz#a6ce3e556e00fd9895dd872dd172ad0d4bd687f4" integrity sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw== +"@types/estree@^1.0.6": + version "1.0.6" + resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.6.tgz#628effeeae2064a1b4e79f78e81d87b7e5fc7b50" + integrity sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw== + "@types/express-serve-static-core@*", "@types/express-serve-static-core@^4.17.33": version "4.19.5" resolved "https://registry.yarnpkg.com/@types/express-serve-static-core/-/express-serve-static-core-4.19.5.tgz#218064e321126fcf9048d1ca25dd2465da55d9c6" @@ -2608,6 +2613,11 @@ acorn@^8.0.0, acorn@^8.0.4, acorn@^8.11.0, acorn@^8.7.1, acorn@^8.8.2: resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.12.0.tgz#1627bfa2e058148036133b8d9b51a700663c294c" integrity sha512-RTvkC4w+KNXrM39/lWCUaG0IbRkWdCv7W/IOW9oU6SawyxulvkQy5HQPVTKxEjczcUvapcrw3cFx/60VN/NRNw== +acorn@^8.14.0: + version "8.14.0" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.14.0.tgz#063e2c70cac5fb4f6467f0b11152e04c682795b0" + integrity sha512-cl669nCJTZBsL97OF4kUQm5g5hC2uihk0NxY3WENAC0TYdILVkAyHymAntgxGkl7K+t0cXIrH5siy5S4XkFycA== + address@^1.0.1, address@^1.1.2: version "1.2.2" resolved "https://registry.yarnpkg.com/address/-/address-1.2.2.tgz#2b5248dac5485a6390532c6a517fda2e3faac89e" @@ -2868,7 +2878,7 @@ body-parser@1.20.2: type-is "~1.6.18" unpipe "1.0.0" -body-parser@1.20.3: +body-parser@1.20.3, body-parser@^1.20.3: version "1.20.3" resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.20.3.tgz#1953431221c6fb5cd63c4b36d53fab0928e548c6" integrity sha512-7rAxByjUMqQ3/bHJy7D6OGXvx/MMc4IqBn/X0fcM1QUcAItpZrBEYhWGem+tzXH90c+G01ypMcYJBO9Y30203g== @@ -2952,6 +2962,16 @@ browserslist@^4.0.0, browserslist@^4.18.1, browserslist@^4.21.10, browserslist@^ node-releases "^2.0.14" update-browserslist-db "^1.0.16" +browserslist@^4.24.0: + version "4.24.2" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.24.2.tgz#f5845bc91069dbd55ee89faf9822e1d885d16580" + integrity sha512-ZIc+Q62revdMcqC6aChtW4jz3My3klmCO1fEmINZY/8J3EpBg5/A/D0AKmBveUh6pgoeycoMkVMko84tuYS+Gg== + dependencies: + caniuse-lite "^1.0.30001669" + electron-to-chromium "^1.5.41" + node-releases "^2.0.18" + update-browserslist-db "^1.1.1" + buffer-from@^1.0.0: version "1.1.2" resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5" @@ -3034,6 +3054,11 @@ caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001599, caniuse-lite@^1.0.30001629: resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001636.tgz#b15f52d2bdb95fad32c2f53c0b68032b85188a78" integrity sha512-bMg2vmr8XBsbL6Lr0UHXy/21m84FTxDLWn2FSqMd5PrlbMxwJlQnC2YWYxVgp66PZE+BBNF2jYQUBKCo1FDeZg== +caniuse-lite@^1.0.30001669: + version "1.0.30001677" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001677.tgz#27c2e2c637e007cfa864a16f7dfe7cde66b38b5f" + integrity sha512-fmfjsOlJUpMWu+mAAtZZZHz7UEwsUxIIvu1TJfO1HqFQvB/B+ii0xr9B5HpbZY/mC4XZ8SvjHJqtAY6pDPQEog== + ccount@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/ccount/-/ccount-2.0.1.tgz#17a3bf82302e0870d6da43a01311a8bc02a3ecf5" @@ -3346,6 +3371,16 @@ cookie@0.6.0: resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.6.0.tgz#2798b04b071b0ecbff0dbb62a505a8efa4e19051" integrity sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw== +cookie@0.7.1: + version "0.7.1" + resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.7.1.tgz#2f73c42142d5d5cf71310a74fc4ae61670e5dbc9" + integrity sha512-6DnInpx7SJ2AK3+CTUE/ZM0vWTUboZCegxhC2xiIydHR9jNuTAASBrfEpHhiGOZw/nX51bHt6YQl8jsGo4y/0w== + +cookie@^0.7.0: + version "0.7.2" + resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.7.2.tgz#556369c472a2ba910f2979891b526b3436237ed7" + integrity sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w== + copy-text-to-clipboard@^3.2.0: version "3.2.0" resolved "https://registry.yarnpkg.com/copy-text-to-clipboard/-/copy-text-to-clipboard-3.2.0.tgz#0202b2d9bdae30a49a53f898626dcc3b49ad960b" @@ -4093,6 +4128,11 @@ dompurify@^3.0.5: resolved "https://registry.yarnpkg.com/dompurify/-/dompurify-3.1.5.tgz#2c6a113fc728682a0f55684b1388c58ddb79dc38" integrity sha512-lwG+n5h8QNpxtyrJW/gJWckL+1/DQiYMX8f7t8Z2AZTPw1esVrqjI63i7Zc2Gz0aKzLVMYC1V1PL/ky+aY/NgA== +"dompurify@^3.0.5 <3.1.7": + version "3.1.6" + resolved "https://registry.yarnpkg.com/dompurify/-/dompurify-3.1.6.tgz#43c714a94c6a7b8801850f82e756685300a027e2" + integrity sha512-cTOAhc36AalkjtBpfG6O8JimdTMWNXjiePT2xQH/ppBGi/4uIpmj8eKyIkMJErXWARyINV/sB38yf8JCLF5pbQ== + domutils@^2.5.2, domutils@^2.8.0: version "2.8.0" resolved "https://registry.yarnpkg.com/domutils/-/domutils-2.8.0.tgz#4437def5db6e2d1f5d6ee859bd95ca7d02048135" @@ -4146,6 +4186,11 @@ electron-to-chromium@^1.4.796: resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.808.tgz#85b2f93a5e32c2949a1a4d39375851945c936835" integrity sha512-0ItWyhPYnww2VOuCGF4s1LTfbrdAV2ajy/TN+ZTuhR23AHI6rWHCrBXJ/uxoXOvRRqw8qjYVrG81HFI7x/2wdQ== +electron-to-chromium@^1.5.41: + version "1.5.50" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.5.50.tgz#d9ba818da7b2b5ef1f3dd32bce7046feb7e93234" + integrity sha512-eMVObiUQ2LdgeO1F/ySTXsvqvxb6ZH2zPGaMYsWzRDdOddUa77tdmI0ltg+L16UpbWdhPmuF3wIQYyQq65WfZw== + elkjs@^0.9.0: version "0.9.3" resolved "https://registry.yarnpkg.com/elkjs/-/elkjs-0.9.3.tgz#16711f8ceb09f1b12b99e971b138a8384a529161" @@ -4241,6 +4286,11 @@ escalade@^3.1.1, escalade@^3.1.2: resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.2.tgz#54076e9ab29ea5bf3d8f1ed62acffbb88272df27" integrity sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA== +escalade@^3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.2.0.tgz#011a3f69856ba189dffa7dc8fcce99d2a87903e5" + integrity sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA== + escape-goat@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/escape-goat/-/escape-goat-4.0.0.tgz#9424820331b510b0666b98f7873fe11ac4aa8081" @@ -4398,74 +4448,74 @@ execa@^5.0.0: signal-exit "^3.0.3" strip-final-newline "^2.0.0" -express@4.20.0: - version "4.20.0" - resolved "https://registry.yarnpkg.com/express/-/express-4.20.0.tgz#f1d08e591fcec770c07be4767af8eb9bcfd67c48" - integrity sha512-pLdae7I6QqShF5PnNTCVn4hI91Dx0Grkn2+IAsMTgMIKuQVte2dN9PeGSSAME2FR8anOhVA62QDIUaWVfEXVLw== +express@^4.17.3: + version "4.19.2" + resolved "https://registry.yarnpkg.com/express/-/express-4.19.2.tgz#e25437827a3aa7f2a827bc8171bbbb664a356465" + integrity sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q== dependencies: accepts "~1.3.8" array-flatten "1.1.1" - body-parser "1.20.3" + body-parser "1.20.2" content-disposition "0.5.4" content-type "~1.0.4" cookie "0.6.0" cookie-signature "1.0.6" debug "2.6.9" depd "2.0.0" - encodeurl "~2.0.0" + encodeurl "~1.0.2" escape-html "~1.0.3" etag "~1.8.1" finalhandler "1.2.0" fresh "0.5.2" http-errors "2.0.0" - merge-descriptors "1.0.3" + merge-descriptors "1.0.1" methods "~1.1.2" on-finished "2.4.1" parseurl "~1.3.3" - path-to-regexp "0.1.10" + path-to-regexp "0.1.7" proxy-addr "~2.0.7" qs "6.11.0" range-parser "~1.2.1" safe-buffer "5.2.1" - send "0.19.0" - serve-static "1.16.0" + send "0.18.0" + serve-static "1.15.0" setprototypeof "1.2.0" statuses "2.0.1" type-is "~1.6.18" utils-merge "1.0.1" vary "~1.1.2" -express@^4.17.3: - version "4.19.2" - resolved "https://registry.yarnpkg.com/express/-/express-4.19.2.tgz#e25437827a3aa7f2a827bc8171bbbb664a356465" - integrity sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q== +express@^4.20.0: + version "4.21.1" + resolved "https://registry.yarnpkg.com/express/-/express-4.21.1.tgz#9dae5dda832f16b4eec941a4e44aa89ec481b281" + integrity sha512-YSFlK1Ee0/GC8QaO91tHcDxJiE/X4FbpAyQWkxAvG6AXCuR65YzK8ua6D9hvi/TzUfZMpc+BwuM1IPw8fmQBiQ== dependencies: accepts "~1.3.8" array-flatten "1.1.1" - body-parser "1.20.2" + body-parser "1.20.3" content-disposition "0.5.4" content-type "~1.0.4" - cookie "0.6.0" + cookie "0.7.1" cookie-signature "1.0.6" debug "2.6.9" depd "2.0.0" - encodeurl "~1.0.2" + encodeurl "~2.0.0" escape-html "~1.0.3" etag "~1.8.1" - finalhandler "1.2.0" + finalhandler "1.3.1" fresh "0.5.2" http-errors "2.0.0" - merge-descriptors "1.0.1" + merge-descriptors "1.0.3" methods "~1.1.2" on-finished "2.4.1" parseurl "~1.3.3" - path-to-regexp "0.1.7" + path-to-regexp "0.1.10" proxy-addr "~2.0.7" - qs "6.11.0" + qs "6.13.0" range-parser "~1.2.1" safe-buffer "5.2.1" - send "0.18.0" - serve-static "1.15.0" + send "0.19.0" + serve-static "1.16.2" setprototypeof "1.2.0" statuses "2.0.1" type-is "~1.6.18" @@ -4573,6 +4623,19 @@ finalhandler@1.2.0: statuses "2.0.1" unpipe "~1.0.0" +finalhandler@1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.3.1.tgz#0c575f1d1d324ddd1da35ad7ece3df7d19088019" + integrity sha512-6BN9trH7bp3qvnrRyzsBz+g3lZxTNZTbVO2EV1CS0WIcDbawYVdYvGflME/9QP0h0pYlCDBCTjYa9nZzMDpyxQ== + dependencies: + debug "2.6.9" + encodeurl "~2.0.0" + escape-html "~1.0.3" + on-finished "2.4.1" + parseurl "~1.3.3" + statuses "2.0.1" + unpipe "~1.0.0" + find-cache-dir@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-4.0.0.tgz#a30ee0448f81a3990708f6453633c733e2f6eec2" @@ -5182,6 +5245,17 @@ http-proxy-middleware@^2.0.3: is-plain-obj "^3.0.0" micromatch "^4.0.2" +http-proxy-middleware@^2.0.7: + version "2.0.7" + resolved "https://registry.yarnpkg.com/http-proxy-middleware/-/http-proxy-middleware-2.0.7.tgz#915f236d92ae98ef48278a95dedf17e991936ec6" + integrity sha512-fgVY8AV7qU7z/MmXJ/rxwbrtQH4jBQ9m7kp3llF0liB7glmFeVZFBepQb32T3y8n8k2+AEYuMPCpinYW+/CuRA== + dependencies: + "@types/http-proxy" "^1.17.8" + http-proxy "^1.18.1" + is-glob "^4.0.1" + is-plain-obj "^3.0.0" + micromatch "^4.0.2" + http-proxy@^1.18.1: version "1.18.1" resolved "https://registry.yarnpkg.com/http-proxy/-/http-proxy-1.18.1.tgz#401541f0534884bbf95260334e72f88ee3976549" @@ -6135,6 +6209,32 @@ mermaid@^10.4.0: uuid "^9.0.0" web-worker "^1.2.0" +mermaid@^10.9.3: + version "10.9.3" + resolved "https://registry.yarnpkg.com/mermaid/-/mermaid-10.9.3.tgz#90bc6f15c33dbe5d9507fed31592cc0d88fee9f7" + integrity sha512-V80X1isSEvAewIL3xhmz/rVmc27CVljcsbWxkxlWJWY/1kQa4XOABqpDl2qQLGKzpKm6WbTfUEKImBlUfFYArw== + dependencies: + "@braintree/sanitize-url" "^6.0.1" + "@types/d3-scale" "^4.0.3" + "@types/d3-scale-chromatic" "^3.0.0" + cytoscape "^3.28.1" + cytoscape-cose-bilkent "^4.1.0" + d3 "^7.4.0" + d3-sankey "^0.12.3" + dagre-d3-es "7.0.10" + dayjs "^1.11.7" + dompurify "^3.0.5 <3.1.7" + elkjs "^0.9.0" + katex "^0.16.9" + khroma "^2.0.0" + lodash-es "^4.17.21" + mdast-util-from-markdown "^1.3.0" + non-layered-tidy-tree-layout "^2.0.2" + stylis "^4.1.3" + ts-dedent "^2.2.0" + uuid "^9.0.0" + web-worker "^1.2.0" + methods@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee" @@ -6724,14 +6824,6 @@ micromark@^4.0.0: micromark-util-symbol "^2.0.0" micromark-util-types "^2.0.0" -micromatch@4.0.8: - version "4.0.8" - resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.8.tgz#d66fa18f3a47076789320b9b1af32bd86d9fa202" - integrity sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA== - dependencies: - braces "^3.0.3" - picomatch "^2.3.1" - micromatch@^4.0.2, micromatch@^4.0.4, micromatch@^4.0.5: version "4.0.7" resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.7.tgz#33e8190d9fe474a9895525f5618eee136d46c2e5" @@ -6740,6 +6832,14 @@ micromatch@^4.0.2, micromatch@^4.0.4, micromatch@^4.0.5: braces "^3.0.3" picomatch "^2.3.1" +micromatch@^4.0.8: + version "4.0.8" + resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.8.tgz#d66fa18f3a47076789320b9b1af32bd86d9fa202" + integrity sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA== + dependencies: + braces "^3.0.3" + picomatch "^2.3.1" + mime-db@1.52.0, "mime-db@>= 1.43.0 < 2": version "1.52.0" resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70" @@ -6885,6 +6985,11 @@ node-releases@^2.0.14: resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.14.tgz#2ffb053bceb8b2be8495ece1ab6ce600c4461b0b" integrity sha512-y10wOWt8yZpqXmOgRo77WaHEmhYQYGNA6y421PKsKYWEK8aW+cqAphborZDhqfyKrbZEN92CN1X2KbafY2s7Yw== +node-releases@^2.0.18: + version "2.0.18" + resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.18.tgz#f010e8d35e2fe8d6b2944f03f70213ecedc4ca3f" + integrity sha512-d9VeXT4SJ7ZeOqGX6R5EM022wpL+eWPooLI+5UpWn2jCT1aosUQEhQP214x33Wkwx3JQMvIm+tIoVOdodFS40g== + non-layered-tidy-tree-layout@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/non-layered-tidy-tree-layout/-/non-layered-tidy-tree-layout-2.0.2.tgz#57d35d13c356643fc296a55fb11ac15e74da7804" @@ -7193,11 +7298,6 @@ path-to-regexp@2.2.1: resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-2.2.1.tgz#90b617025a16381a879bc82a38d4e8bdeb2bcf45" integrity sha512-gu9bD6Ta5bwGrrU8muHzVOBFFREpp2iRkVfhBJahwJ6p6Xw20SjT0MxLnwkjOibQmGSYhiUnf2FLe7k+jcFmGQ== -path-to-regexp@3.3.0: - version "3.3.0" - resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-3.3.0.tgz#f7f31d32e8518c2660862b644414b6d5c63a611b" - integrity sha512-qyCH421YQPS2WFDxDjftfc1ZR5WKQzVzqsp4n9M2kQhVOo/ByahFoUNJfl58kOcEGfQ//7weFTDhm+ss8Ecxgw== - path-to-regexp@^1.7.0: version "1.8.0" resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-1.8.0.tgz#887b3ba9d84393e87a0a0b9f4cb756198b53548a" @@ -7205,6 +7305,13 @@ path-to-regexp@^1.7.0: dependencies: isarray "0.0.1" +path-to-regexp@^1.9.0: + version "1.9.0" + resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-1.9.0.tgz#5dc0753acbf8521ca2e0f137b4578b917b10cf24" + integrity sha512-xIp7/apCFJuUHdDLWe8O1HIkb0kQrOMb/0u6FXQjemHn/ii5LrIzU6bdECnsiTF/GjZkMEKg1xdiZwNqDYlZ6g== + dependencies: + isarray "0.0.1" + path-type@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b" @@ -7224,6 +7331,11 @@ picocolors@^1.0.0, picocolors@^1.0.1: resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.0.1.tgz#a8ad579b571952f0e5d25892de5445bcfe25aaa1" integrity sha512-anP1Z8qwhkbmu7MFP5iTt+wQKXgwzf7zTyGlcdzabySa9vd0Xt392U0rVmz9poOaBj0uHJKyyo9/upk0HrEQew== +picocolors@^1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.1.1.tgz#3d321af3eab939b083c8f929a1d12cda81c26b6b" + integrity sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA== + picomatch@^2.0.4, picomatch@^2.2.1, picomatch@^2.2.3, picomatch@^2.3.1: version "2.3.1" resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" @@ -8274,6 +8386,25 @@ send@0.19.0: range-parser "~1.2.1" statuses "2.0.1" +send@^0.19.0: + version "0.19.1" + resolved "https://registry.yarnpkg.com/send/-/send-0.19.1.tgz#1c2563b2ee4fe510b806b21ec46f355005a369f9" + integrity sha512-p4rRk4f23ynFEfcD9LA0xRYngj+IyGiEYyqqOak8kaN0TvNmuxC2dcVeBn62GpCeR2CpWqyHCNScTP91QbAVFg== + dependencies: + debug "2.6.9" + depd "2.0.0" + destroy "1.2.0" + encodeurl "~2.0.0" + escape-html "~1.0.3" + etag "~1.8.1" + fresh "0.5.2" + http-errors "2.0.0" + mime "1.6.0" + ms "2.1.3" + on-finished "2.4.1" + range-parser "~1.2.1" + statuses "2.0.1" + serialize-javascript@^6.0.0, serialize-javascript@^6.0.1: version "6.0.2" resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-6.0.2.tgz#defa1e055c83bf6d59ea805d8da862254eb6a6c2" @@ -8318,15 +8449,15 @@ serve-static@1.15.0: parseurl "~1.3.3" send "0.18.0" -serve-static@1.16.0: - version "1.16.0" - resolved "https://registry.yarnpkg.com/serve-static/-/serve-static-1.16.0.tgz#2bf4ed49f8af311b519c46f272bf6ac3baf38a92" - integrity sha512-pDLK8zwl2eKaYrs8mrPZBJua4hMplRWJ1tIFksVC3FtBEBnl8dxgeHtsaMS8DhS9i4fLObaon6ABoc4/hQGdPA== +serve-static@1.16.2, serve-static@^1.16.0: + version "1.16.2" + resolved "https://registry.yarnpkg.com/serve-static/-/serve-static-1.16.2.tgz#b6a5343da47f6bdd2673848bf45754941e803296" + integrity sha512-VqpjJZKadQB/PEbEwvFdO43Ax5dFBZ2UECszz8bQ7pi7wt//PWe1P6MN7eCnjsatYtBT6EuiClbjSWP2WrIoTw== dependencies: - encodeurl "~1.0.2" + encodeurl "~2.0.0" escape-html "~1.0.3" parseurl "~1.3.3" - send "0.18.0" + send "0.19.0" set-function-length@^1.2.1: version "1.2.2" @@ -8950,6 +9081,14 @@ update-browserslist-db@^1.0.16: escalade "^3.1.2" picocolors "^1.0.1" +update-browserslist-db@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.1.1.tgz#80846fba1d79e82547fb661f8d141e0945755fe5" + integrity sha512-R8UzCaa9Az+38REPiJ1tXlImTJXlVfgHZsglwBD/k6nj76ctsH1E3q4doGrukiLQd3sGQYu56r5+lo5r94l29A== + dependencies: + escalade "^3.2.0" + picocolors "^1.1.0" + update-notifier@^6.0.2: version "6.0.2" resolved "https://registry.yarnpkg.com/update-notifier/-/update-notifier-6.0.2.tgz#a6990253dfe6d5a02bd04fbb6a61543f55026b60" @@ -9165,11 +9304,12 @@ webpack-sources@^3.2.3: resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-3.2.3.tgz#2d4daab8451fd4b240cc27055ff6a0c2ccea0cde" integrity sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w== -webpack@5.94.0: - version "5.94.0" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.94.0.tgz#77a6089c716e7ab90c1c67574a28da518a20970f" - integrity sha512-KcsGn50VT+06JH/iunZJedYGUJS5FGjow8wb9c0v5n1Om8O1g4L6LjtfxwlXIATopoQu+vOXXa7gYisWxCoPyg== +webpack@^5.88.1: + version "5.92.1" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.92.1.tgz#eca5c1725b9e189cffbd86e8b6c3c7400efc5788" + integrity sha512-JECQ7IwJb+7fgUFBlrJzbyu3GEuNBcdqr1LD7IbSzwkSmIevTm8PF+wej3Oxuz/JFBUZ6O1o43zsPkwm1C4TmA== dependencies: + "@types/eslint-scope" "^3.7.3" "@types/estree" "^1.0.5" "@webassemblyjs/ast" "^1.12.1" "@webassemblyjs/wasm-edit" "^1.12.1" @@ -9178,7 +9318,7 @@ webpack@5.94.0: acorn-import-attributes "^1.9.5" browserslist "^4.21.10" chrome-trace-event "^1.0.2" - enhanced-resolve "^5.17.1" + enhanced-resolve "^5.17.0" es-module-lexer "^1.2.1" eslint-scope "5.1.1" events "^3.2.0" @@ -9194,21 +9334,20 @@ webpack@5.94.0: watchpack "^2.4.1" webpack-sources "^3.2.3" -webpack@^5.88.1: - version "5.92.1" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.92.1.tgz#eca5c1725b9e189cffbd86e8b6c3c7400efc5788" - integrity sha512-JECQ7IwJb+7fgUFBlrJzbyu3GEuNBcdqr1LD7IbSzwkSmIevTm8PF+wej3Oxuz/JFBUZ6O1o43zsPkwm1C4TmA== +webpack@^5.94.0: + version "5.96.1" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.96.1.tgz#3676d1626d8312b6b10d0c18cc049fba7ac01f0c" + integrity sha512-l2LlBSvVZGhL4ZrPwyr8+37AunkcYj5qh8o6u2/2rzoPc8gxFJkLj1WxNgooi9pnoc06jh0BjuXnamM4qlujZA== dependencies: - "@types/eslint-scope" "^3.7.3" - "@types/estree" "^1.0.5" + "@types/eslint-scope" "^3.7.7" + "@types/estree" "^1.0.6" "@webassemblyjs/ast" "^1.12.1" "@webassemblyjs/wasm-edit" "^1.12.1" "@webassemblyjs/wasm-parser" "^1.12.1" - acorn "^8.7.1" - acorn-import-attributes "^1.9.5" - browserslist "^4.21.10" + acorn "^8.14.0" + browserslist "^4.24.0" chrome-trace-event "^1.0.2" - enhanced-resolve "^5.17.0" + enhanced-resolve "^5.17.1" es-module-lexer "^1.2.1" eslint-scope "5.1.1" events "^3.2.0" diff --git a/doc/plutus-core-spec/Makefile b/doc/plutus-core-spec/Makefile index 861007cebc6..25ebf1cc5e2 100644 --- a/doc/plutus-core-spec/Makefile +++ b/doc/plutus-core-spec/Makefile @@ -5,14 +5,14 @@ BIB=${DOC}.bib FIGS=./figures -SRC = *.tex cardano/*.tex ${BIB} # ${FIGS}/*.tex +SRC = *.tex cardano/*.tex ${BIB} # ${FIGS}/*.tex LATEX = pdflatex -halt-on-error -shell-escape # To get pstricks to work with PDF BIBTEX = bibtex MAKEINDEX = makeindex -.PHONEY: all pdf figs again clean +.PHONEY: all pdf figs again clean #---------------------------------------------------------------- @@ -36,7 +36,7 @@ figs: cd ${FIGS} && ${MAKE} #---------------------------------------------------------------- -again: +again: touch ${DOC}.tex && ${MAKE} clean: diff --git a/doc/plutus-core-spec/builtins.tex b/doc/plutus-core-spec/builtins.tex index 472b8f4ac48..38b7fe4db2b 100644 --- a/doc/plutus-core-spec/builtins.tex +++ b/doc/plutus-core-spec/builtins.tex @@ -115,7 +115,7 @@ \subsubsection{Type variables} $$ \kindstar{v} \text{\quad if $v \in \Var_*$}. $$ - + \kwxm{I'm using syntax to represent kinds here. I haven't introduced actual kinds because (a) we don't have a proper type system in Plutus Core (yet), and (b) the \texttt{TypeScheme} type in the implementation only has one kind of @@ -209,7 +209,7 @@ \subsubsection{Type assignments} \begin{itemize} \item $T = P$ and $S =\varnothing$. \item $P \in \Var_\#$ and $S = \{(v_\#, T)\}$. - \item + \item \begin{itemize} \item $T = \op(T_1, \ldots, T_n)$ with each $T_i \in \Uni$. \item $P = \op(P_1, \ldots, P_n)$ with each $P_i \in \Unihash$. @@ -224,7 +224,7 @@ \subsubsection{Type assignments} \kwxm{\sf I tried using inference rules for this but the final case got kind of out of hand.} - + \subsection{Built-in functions} \label{sec:builtin-functions} @@ -365,7 +365,7 @@ \subsubsection{Signatures and denotations of built-in functions} \medskip \noindent Also, given an arity $= [\iota_1, \ldots, \iota_n]$, the \textit{reduced - arity} is + arity} is $$ \alphabar = [\iota_j : \iota_j \notin \QVar]. $$% @@ -522,7 +522,7 @@ \subsubsection{Parametricity for *-polymorphic arguments} %% \end{array}\] %% \end{minipage} - + \subsection{Evaluation of built-in functions} \label{sec:builtin-evaluation} @@ -548,7 +548,7 @@ \subsubsection{Compatibility of inputs and signature entries} returning a constant of a third type. However, I think it'll be very hard to describe what's actually going on so I'm just assuming that builtins always check this stuff.} - + \medskip \noindent In detail, given a reduced arity $\alphabar = [\tau_1, \ldots, diff --git a/doc/plutus-core-spec/cardano/builtins1.tex b/doc/plutus-core-spec/cardano/builtins1.tex index f2707c6f22d..f82c829e9ec 100644 --- a/doc/plutus-core-spec/cardano/builtins1.tex +++ b/doc/plutus-core-spec/cardano/builtins1.tex @@ -33,7 +33,7 @@ \subsubsection{Built-in types and type operators} \texttt{data} & See below & See below\\ \hline \end{tabular} - \caption{Atomic types, batch 1} + \caption{Atomic types, Batch 1} \label{table:built-in-types-1} \end{table} @@ -47,7 +47,7 @@ \subsubsection{Built-in types and type operators} \texttt{pair} & 2 & $\denote{\pairOf{t_1}{t_2}} = \denote{t_1} \times \denote{t_2}$ & See below\\ \hline \end{tabular} - \caption{Type operators, batch 1} + \caption{Type operators, Batch 1} \label{table:built-in-type-operators-1} \end{table} @@ -160,10 +160,10 @@ \subsubsection{Built-in types and type operators} constants are \begin{verbatim} - (con data (Constr 1 [(I 2), (B #), (Map [])]) - (con data (Map [((I 0), (B #00)), ((I 1), (B #0F))])) - (con data (List [(I 0), (I 1), (B #7FFF), (List []]))) - (con data (I -22)) + (con data (Constr 1 [(I 2), (B #), (Map [])]) + (con data (Map [((I 0), (B #00)), ((I 1), (B #0F))])) + (con data (List [(I 0), (I 1), (B #7FFF), (List []]))) + (con data (I -22)) (con data (B #001A)). \end{verbatim} % TODO: be more relaxed about parenthesisation in general @@ -204,13 +204,13 @@ \subsubsection{Built-in functions} \hline \endhead \hline - \caption{Built-in functions, batch 1} + \caption{Built-in functions, Batch 1} % This caption goes on every page of the table except the last. Ideally it % would appear only on the first page and all the rest would say % (continued). Unfortunately it doesn't seem to be easy to do that in a % longtable. \endfoot - \caption[]{Built-in functions, batch 1 (continued)} + \caption[]{Built-in functions, Batch 1 (continued)} \label{table:built-in-functions-1} \endlastfoot \TT{addInteger} & $[\ty{integer}, \ty{integer}] \to \ty{integer}$ & $+$ & No & \\[2mm] @@ -300,7 +300,7 @@ \subsubsection{Built-in functions} \TT{mkPairData} & $[\ty{data}, \ty{data}]$ \text{\;\; $\to \pairOf{\ty{data}}{\ty{data}}$} & $(x,y) \mapsto (x,y) $ & No & \\[2mm] \TT{mkNilData} & $[\ty{unit}] \to \listOf{\ty{data}} $ & $() \mapsto []$ & No & \\[2mm] \TT{mkNilPairData} & $[\ty{unit}] $ \text{$\;\; \to \listOf{\pairOf{\ty{data}}{\ty{data}}} $} & $() \mapsto []$ & No & \\[2mm] - \hline + \hline \end{longtable} \kwxm{Maybe try \texttt{tabulararray} to see what sort of output that gives for the big table.} @@ -325,6 +325,9 @@ \subsubsection{Built-in functions} $$ |\remfn(a,b)| < |b|. $$ +\nomenclature[Azz]{$\divfn$, $\modfn$}{Integer division operations} +\nomenclature[Azz]{$\quotfn$, $\remfn$}{Integer division operations} + \noindent The $\divfn$ and $\modfn$ functions form a pair, as do $\quotfn$ and $\remfn$; $\divfn$ should not be used in combination with $\modfn$, not should $\quotfn$ be used with $\modfn$. @@ -361,10 +364,11 @@ \subsubsection{Built-in functions} \note{The \texttt{consByteString} function.} \label{note:consbytestring} -In built-in semantics 1, the first argument of \texttt{consByteString} is an -arbitrary integer which will be reduced modulo 256 before being prepended to the -second argument. In built-in semantics 2 we require that the first argument lies between 0 -and 255 (inclusive): in any other case an error will occur. +In built-in semantics varinat 1, the first argument of \texttt{consByteString} +is an arbitrary integer which will be reduced modulo 256 before being prepended +to the second argument. In built-in semantics varaint 2 we require that the first +argument lies between 0 and 255 (inclusive): in any other case an error will +occur. \note{The \texttt{sliceByteString} function.} \label{note:slicebytestring} @@ -439,7 +443,7 @@ \subsubsection{Built-in functions} digital signature verification function takes three bytestring arguments (in the given order): \begin{itemize} - \item a public key $\vk$ (in this context $\vk$ is also known as a \textit{verification key}) + \item a public key $\vk$ (in this context $\vk$ is also known as a \textit{verification key}) \item a message $m$ \item a signature $s$. \end{itemize} @@ -465,8 +469,6 @@ \subsubsection{Built-in functions} \item $s$: 64 bytes. \end{itemize} - - \note{The \texttt{trace} function.} \label{note:trace} An application \texttt{[(builtin trace) $s$ $v$]} ($s$ a \texttt{string}, $v$ diff --git a/doc/plutus-core-spec/cardano/builtins2.tex b/doc/plutus-core-spec/cardano/builtins2.tex index a7c9ad37be0..361ddab3a97 100644 --- a/doc/plutus-core-spec/cardano/builtins2.tex +++ b/doc/plutus-core-spec/cardano/builtins2.tex @@ -29,9 +29,9 @@ \subsubsection{Built-in functions} \hline \endhead \hline - \caption{Built-in functions, batch 2} + \caption{Built-in functions, Batch 2} \endfoot - \caption[]{Built-in functions, batch 2} + \caption[]{Built-in functions, Batch 2} \label{table:built-in-functions-2} \endlastfoot \TT{serialiseData} & $[\ty{data}] \to \ty{bytestring}$ & $\mathcal{E}_{\mathtt{data}}$ & No diff --git a/doc/plutus-core-spec/cardano/builtins3.tex b/doc/plutus-core-spec/cardano/builtins3.tex index 8c3c3a2cc2c..21fbe8c728e 100644 --- a/doc/plutus-core-spec/cardano/builtins3.tex +++ b/doc/plutus-core-spec/cardano/builtins3.tex @@ -29,9 +29,9 @@ \subsubsection{Built-in functions} \hline \endhead \hline - \caption{Built-in functions, batch 3} + \caption{Built-in functions, Batch 3} \endfoot - \caption[]{Built-in functions, batch 3} + \caption[]{Built-in functions, Batch 3} \label{table:built-in-functions-3} \endlastfoot \TT{verifyEcdsaSecp256k1Signature} & $[\ty{bytestring}, \ty{bytestring}, $ \text{$\;\; \ty{bytestring}] \to \ty{bool}$} @@ -57,12 +57,21 @@ \subsubsection{Built-in functions} \item $s$: 64 bytes. \end{itemize} The public key $\vk$ is expected to be in the 33-byte compressed form described -in~\cite{Bitcoin-ECDSA}. Moreover, the ECDSA scheme admits two distinct valid +in~\cite{Bitcoin-ECDSA}. It is expected that the inputs to the function are +well formed, and if they are not then an error will occur. For example, the +signature $s$ encodes a pair $(R,S)$ of 32-byte bytestrings which are big-endian +encodings of integers, and both of these integers must lie between 0 and +$\left|G\right|-1$ (inclusive), where $G$ is the relevant subgroup of the +\texttt{secp256k1} curve; it is also required that the last 32 bytes of the +verification key are the big-endian encoding of the $x$-coordinate of a point in +$G$. + +Moreover, the ECDSA scheme admits two distinct valid signatures for a given message and private key, and we follow the restriction imposed by Bitcoin (see~\cite{BIP-146}, \texttt{LOW\_S}) and \textbf{only accept the smaller signature}; \texttt{verifyEcdsa\-Secp\-256k1Signature} will return $\false$ if the larger -one is supplied. +one is supplied. % For more on the lower signature business, see % https://github.com/IntersectMBO/plutus/pull/4591#issuecomment-1120797931 @@ -90,3 +99,4 @@ \subsubsection{Built-in functions} \item $m$: unrestricted \item $s$: 64 bytes. \end{itemize} +\noindent Any deviation from the conditions of BIP-340~\cite{BIP-340} will cause an error. diff --git a/doc/plutus-core-spec/cardano/builtins4.tex b/doc/plutus-core-spec/cardano/builtins4.tex index 98bb84e9812..1c958d5360a 100644 --- a/doc/plutus-core-spec/cardano/builtins4.tex +++ b/doc/plutus-core-spec/cardano/builtins4.tex @@ -37,7 +37,7 @@ \subsubsection{Miscellaneous built-in functions} % (continued). Unfortunately it doesn't seem to be easy to do that in a % longtable. \endfoot -%% \caption[]{Built-in functions, batch 4} +%% \caption[]{Built-in functions, Batch 4} \caption[]{Batch 4: miscellaneous built-in functions} \label{table:misc-built-in-functions-4} \endlastfoot @@ -94,7 +94,7 @@ \subsubsection{Miscellaneous built-in functions} the case $n=0$: $$ -\itobsLE (w,n) = \itobsBE (w,n) = +\itobsLE (w,n) = \itobsBE (w,n) = \begin{cases} \errorX & \text{if $n<0$ or $n \geq 2^{65536}$}\\ \errorX & \text{if $w<0$ or $w > 8192$}\\ @@ -144,7 +144,7 @@ \subsubsection{Miscellaneous built-in functions} \item A boolean endianness flag $e$. \item The bytestring $s$ to be converted. \end{itemize} -\noindent +\noindent The conversion is little-endian if $e$ is \texttt{(con bool False)} and big-endian if $e$ is \texttt{(con bool True)}. In both cases the empty bytestring is converted to the integer 0. All bytestrings are legal inputs and there is no @@ -179,16 +179,16 @@ \subsubsection{BLS12-381 built-in types} $\TyMlResult$ & $\MlResultDenotation$ & None (see Note~\ref{note:bls-syntax})\\ \hline \end{tabular} - \caption{Atomic types, batch 4} + \caption{Atomic types, Batch 4} \label{table:built-in-types-4} \end{table} %% \paragraph{$G_1$ and $G_2$}. -\noindent Here $G_1$ and $G_2$ are both additive cyclic groups of prime order $r$, where +\noindent Here $G_1$ and $G_2$ are both additive cyclic groups of prime order $r$, where $$ r = \mathtt{0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001}. $$ - + \paragraph{The fields $\Fq$ and $\Fqq$.} \noindent To define the groups $G_1$ and $G_2$ we need the finite field $\Fq$ where \begin{align*} @@ -294,7 +294,7 @@ \subsubsection{BLS12-381 built-in functions} \TT{bls12\_381\_G1\_uncompress} & $[ \ty{bytestring}]$ \text{\: $ \to \ty{bls12\_381\_G1\_element}$} & $\uncompress_{G_1}$ & Yes & \ref{note:group-uncompression}\\[2mm] - \hline + \hline %% G2 \TT{bls12\_381\_G2\_add} & $[ \ty{bls12\_381\_G2\_element}$, @@ -319,7 +319,7 @@ \subsubsection{BLS12-381 built-in functions} \TT{bls12\_381\_G2\_uncompress} & $[ \ty{bytestring}]$ \text{\: $ \to \ty{bls12\_381\_G2\_element}$} & $\uncompress_{G_2}$ & Yes & \ref{note:group-uncompression}\\[2mm] - \hline + \hline \TT{bls12\_381\_millerLoop} & $[ \ty{bls12\_381\_G1\_element}$, \text{\; $\ty{bls12\_381\_G2\_element} ]$} @@ -359,7 +359,7 @@ \subsubsection{BLS12-381 built-in functions} \newcommand{\ymin}{y_{\text{min}}} \newcommand{\ymax}{y_{\text{max}}} -\note{Compression for elements of $G_1$ and $G_2$.} +\note{Compression for elements of $G_1$ and $G_2$.} \label{note:group-compression} Points in $G_1$ and $G_2$ are encoded as bytestrings in a ``compressed'' format where only the $x$-coordinate of a point is encoded and some metadata is used to @@ -397,9 +397,9 @@ \subsubsection{BLS12-381 built-in functions} \noindent Thus in all cases the encoding of an element of $G_1$ requires exactly 384 bits, or 48 bytes. -\medskip +\medskip -\noindent +\noindent \begin{itemize} \item Similarly, every non-identity element of $G_2$ can be written in the form $(x,y)$ with $x,y \in \Fqq$. We define @@ -427,7 +427,7 @@ \subsubsection{BLS12-381 built-in functions} $y$-coordinates of a point are encoded, and in that case the leading bit of the encoded point is 0. We do not support this format. -\note{Uncompression for elements of $G_1$ and $G_2$.} +\note{Uncompression for elements of $G_1$ and $G_2$.} \label{note:group-uncompression} There are two (partial) ``uncompression'' functions $\uncompress_{G_1}$ and $\uncompress_{G_2}$ which convert bytestrings into group elements; these are diff --git a/doc/plutus-core-spec/cardano/builtins5.tex b/doc/plutus-core-spec/cardano/builtins5.tex index e79fd7ffe6d..90dc77a0e84 100644 --- a/doc/plutus-core-spec/cardano/builtins5.tex +++ b/doc/plutus-core-spec/cardano/builtins5.tex @@ -18,6 +18,9 @@ \subsection{Batch 5} \label{sec:default-builtins-5} + +\subsubsection{Built-in functions} +\label{sec:built-in-functions-5} The fifth batch of built-in functions adds support for \begin{itemize} \item Logical and bitwise operations on bytestrings (see~\cite{CIP-0122} and~\cite{CIP-0123}). @@ -49,9 +52,9 @@ \subsection{Batch 5} \hline \endhead \hline - \caption{Built-in functions, batch 5} + \caption{Built-in functions, Batch 5} \endfoot - \caption[]{Built-in functions, batch 5} + \caption[]{Built-in functions, Batch 5} \label{table:built-in-functions-5} \endlastfoot \TT{andByteString} & $[\ty{bool}, \ty{bytestring}, \ty{bytestring}] $ \text{$\;\; \to \ty{bytestring}$} & $\Xand$ & No & \ref{note:bitwise-logical-ops} \\[2mm] @@ -88,10 +91,10 @@ \subsection{Batch 5} bytestrings have different lengths. \begin{itemize} -\item If the first argument of one of the bitwise logical operations is $\false$ +\item If the first argument of one of the bitwise logical operations is $\false$ then the longer bytestring is (conceptually) truncated on the right to have the same length as the shorter one. -\item If the first argument is $\true$ +\item If the first argument is $\true$ then the shorter bytestring is (conceptually) extended on the right to have the same length as the longer one. In the case of $\Xand$ the shorter bytestring is extended with $\bitzero$ bits and in the case of $\Xor$ and $\Xxor$ it is @@ -120,7 +123,7 @@ \subsection{Batch 5} is a bitstring of length $n$: \begin{align*} -\Xand\,(\false, b, c) &= d_{l-1} \cdots d_0 +\Xand\,(\false, b, c) &= d_{l-1} \cdots d_0 \quad \text{where $l=\min\{m,n\}$ and $d_i = \trunc\,(b,m-l)_i \wedge \trunc\,(c,n-l)_i$}\\ \Xand\,(\true, b, c) &= d_{l-1} \cdots d_0 \quad \text{where $l=\max\{m,n\}$ and $d_i = \ext\,(b,l-m,\bitone)_i \wedge \ext\,(c,l-n,\bitone)_i$} @@ -129,14 +132,14 @@ \subsection{Batch 5} \begin{align*} \Xor\,(\false, b, c) &= d_{l-1} \cdots d_0 \quad \text{where $l=\min\{m,n\}$ and $d_i = \trunc\,(b,m-l)_i \vee \trunc\,(c,n-l)_i$}\\ -\Xor\,(\true, b, c) &= d_{l-1} \cdots d_0 +\Xor\,(\true, b, c) &= d_{l-1} \cdots d_0 \quad \text{where $l=\max\{m,n\}$ and $d_i = \ext\,(b,l-m,\bitzero)_i \vee \ext\,(c,l-n,\bitzero)_i$} \end{align*} % \begin{align*} \Xxor\,(\false, b, c) &= d_{l-1} \cdots d_0 \quad \text{where $l=\min\{m,n\}$ and $d_i = \trunc\,(b,m-l)_i \oplus \trunc\,(c,n-l)_i$}\\ -\Xxor\,(\true, b, c) &= d_{l-1} \cdots d_0 +\Xxor\,(\true, b, c) &= d_{l-1} \cdots d_0 \quad \text{where $l=\max\{m,n\}$ and $d_i = \ext\,(b,l-m,\bitzero)_i \oplus \ext\,(c,l-n,\bitzero)_i$}. \end{align*} @@ -170,7 +173,7 @@ \subsection{Batch 5} and rotates the bits of $s$ $k$ places to the left if $k \geq 0$ and $k$ places to the right if $k < 0$. The length of the output bytestring is the same as that of the input. The denotation of -\texttt{rotateByteString} (defined on the bitstring representation of $s$) is +\texttt{rotateByteString} (defined on the bitstring representation of $s$) is $$ \mathsf{rotate}\,(b_{n-1} \cdots b_0, k) = d_{n-1}\cdots d_0 \quad\text{where $d_i = b_{(i-k)\bmod n}$}. @@ -203,9 +206,9 @@ \subsection{Batch 5} contain repetitions. \smallskip -\noindent Formally, +\noindent Formally, $$ -\mathsf{writeBits}(b_{n-1}{\cdots}b_0, [j_0, \ldots, j_{l-1}], u) = +\mathsf{writeBits}(b_{n-1}{\cdots}b_0, [j_0, \ldots, j_{l-1}], u) = \begin{cases} \errorX & \text{if $\exists k \in \{0, \ldots, l-1\}$ such that $j_k < 0$ or $j_k \geq n$} \\ d_{n-1}{\cdots}d_0 & \text{otherwise} diff --git a/doc/plutus-core-spec/cardano/builtins6.tex b/doc/plutus-core-spec/cardano/builtins6.tex new file mode 100644 index 00000000000..a31c1f32a9a --- /dev/null +++ b/doc/plutus-core-spec/cardano/builtins6.tex @@ -0,0 +1,58 @@ +% I tried resetting the note number from V1-builtins here, but that made +% some hyperlinks wrong. To get note numbers starting at one in each section, I +% think we have to define a new counter every time. +\newcounter{notenumberF} +\renewcommand{\note}[1]{ + \bigskip + \refstepcounter{notenumberF} + \noindent\textbf{Note \thenotenumberF. #1} +} + +\subsection{Batch 6} +\label{sec:default-builtins-6} + +\subsubsection{Built-in functions} +\label{sec:built-in-functions-6} +The 6th batch of builtin operations is defined in Table~\ref{table:built-in-functions-6}. + +\setlength{\LTleft}{2mm} % Shift the table right a bit to centre it on the page +\begin{longtable}[H]{|l|p{67mm}|p{18mm}|c|c|} + \hline + \text{Function} & \text{Signature} & \text{Denotation} & \text{Can} & \text{Note} \\ + & & & fail? & \\ + \hline + \endfirsthead + \hline + \text{Function} & \text{Type} & \text{Denotation} & \text{Can} & \text{Note}\\ + & & & fail? & \\ + \hline + \endhead + \hline + \caption{Built-in functions, Batch 6} + \endfoot + \caption[]{Built-in functions, Batch 6} + \label{table:built-in-functions-6} + \endlastfoot + \TT{expModInteger} & $[\ty{integer}, \ty{integer}, $ \text{$\;\; \ty{integer}] \to \ty{integer}$} + & $\mathsf{expMod} $ & Yes & \ref{note:exp-mod-integer}\\ +\hline +\end{longtable} + +\note{Modular Exponentiation.} +\label{note:exp-mod-integer} +The \texttt{expModInteger} function performs modular exponentiation. Its denotation +$\mathsf{expMod}: \Z \times \Z \times \Z \rightarrow \Z_{\errorX}$ is given by + +$$ +\mathsf{expMod}(a,e,m) = + \begin{cases} + \modfn(a^e,m) & \text{if $m > 0$ and $e \geq 0$}\\ + \min\{r \in \N: ra^{-e} \equiv 1\pmod{m}\}\ & \text{if $m > 0, e < 0$ and $\mathrm{gcd}(a,m) = 1$}\\ + \errorX & \text{otherwise.} + \end{cases} +$$ + +\noindent The fact that this is well defined for the case $e<0$ and $\mathrm{gcd}(a,m) = 1$ +follows, for example, from Proposition I.3.1 of~\cite{Koblitz-GTM}. See +Note~\ref{note:integer-division-functions} of +Section~\ref{sec:built-in-functions-1} for the definition of $\modfn$. diff --git a/doc/plutus-core-spec/cardano/cardano.tex b/doc/plutus-core-spec/cardano/cardano.tex index adc669ea828..966052624c5 100644 --- a/doc/plutus-core-spec/cardano/cardano.tex +++ b/doc/plutus-core-spec/cardano/cardano.tex @@ -79,6 +79,8 @@ \section{Built-in types and functions} \input{cardano/builtins2.tex} \input{cardano/builtins3.tex} \input{cardano/builtins4.tex} +\newpage %% Bad page break between table and caption otherwise. \input{cardano/builtins5.tex} +\input{cardano/builtins6.tex} diff --git a/doc/plutus-core-spec/data-cbor.tex b/doc/plutus-core-spec/data-cbor.tex index fb3e7a6db5d..9c2544840d8 100644 --- a/doc/plutus-core-spec/data-cbor.tex +++ b/doc/plutus-core-spec/data-cbor.tex @@ -42,7 +42,7 @@ \section{Notation} We introduce some extra notation for use here and in Appendix~\ref{appendix:flat-serialisation}. -\medskip +\medskip \noindent The notation $f: X \rightharpoonup Y$ indicates that $f$ is a partial map from $X$ to $Y$. We denote the empty bytestring by $\epsilon$ and (as in~\ref{sec:notation-lists}) use $\length(s)$ to denote the length of a @@ -76,7 +76,7 @@ \section{Notation} often be built up from decoders for simpler types. Decoders are \textit{partial} functions because they can fail, for instance, if there is insufficient input, or if the input is not well formed, or if a decoded value is -outside some specified range. +outside some specified range. Many of the decoders which we define below involve a number of cases for different forms of input, and we implicitly assume that the decoder fails if @@ -120,7 +120,7 @@ \section{Encoding and decoding the heads of CBOR items} $$ \bsToInt_k(s) = (s', \sum_{i=0}^{k-1}256^ib_i) \qquad \text{if $s = [b_{k-1}, \ldots, b_0] \cdot s'$}. $$ - + \noindent We now define an encoder $\eHead: \Nab{0}{7} \times \Nab{0}{2^{64}-1} \rightarrow \B^*$ which takes a major type and a natural number and encodes them as a CBOR head using the standard encoding: @@ -137,7 +137,7 @@ \section{Encoding and decoding the heads of CBOR items} $$ \noindent The corresponding decoder $\dHead: \B^* \rightharpoonup \B^* \times -\Nab{0}{7} \times \Nab{0}{2^{64}-1}$ is given by +\Nab{0}{7} \times \Nab{0}{2^{64}-1}$ is given by $$ \dHead(n \cdot s) = @@ -174,7 +174,7 @@ \section{Encoding and decoding the heads of CBOR items} \eIndef(m) &= [32m+31]\\ \dIndef(n \cdot s) & = (s, m) \qquad \text{if $n = 32m+31$}. \end{align*} - + \noindent Note that $\eIndef$ and $\dIndef$ are only defined for $m \in \{2,3,4,5\}$ (and we shall only use them in these cases). The case $m=31$ corresponds to the break byte and for $m \in \{0,1,6\}$ the value is not well @@ -190,14 +190,14 @@ \section{Encoding and decoding bytestrings} the \textit{canonical 64-byte decomposition} $\bar{a}$ of $a$ to be $$ \bar{a} = [[a_1, \ldots, a_{64}], - [a_{65}, \ldots, a_{128}] ,\ldots, + [a_{65}, \ldots, a_{128}] ,\ldots, [a_{64(k-1)+1}, \ldots, a_{64k}]] \in (\B^*)^* $$ \noindent if $r=0$ and $$ \bar{a} = [[a_1, \ldots, a_{64}], - [a_{65}, \ldots, a_{128}], \ldots, + [a_{65}, \ldots, a_{128}], \ldots, [a_{64(k-1)+1}, \ldots, a_{64k}], [a_{64k+1}, \ldots, a_{64k+r}]] \in (\B^*)^* $$ \noindent if $r>0$. The canonical decomposition of the empty list is $\bar{\epsilon} = []$. @@ -299,7 +299,7 @@ \section{Encoding and decoding integers} \end{cases} $$ -\noindent +\noindent The encoder $\eZ: \Z \rightarrow \B^*$ for integers is now defined by $$ \eZ(n) = \begin{cases} @@ -344,10 +344,10 @@ \section{Encoding and decoding \texttt{data}} \paragraph{The encoder.} The encoder is given by \begin{alignat*}{2} -& \eData(\mathtt{Map}\: l) && = \eHead(5,\length(l)) \cdot \eDataStarSq(l)\\ -& \eData(\mathtt{List}\: l) && = \eIndef(4) \cdot \eDataStar(l) \cdot 255\\ +& \eData(\mathtt{Map}\: l) && = \eHead(5,\length(l)) \cdot \eDataStarSq(l)\\ +& \eData(\mathtt{List}\: l) && = \eIndef(4) \cdot \eDataStar(l) \cdot 255\\ & \eData(\mathtt{Constr}\: i\, l) && = \ecTag(i) \cdot \eIndef(4) \cdot \eDataStar(l) \cdot 255\\ -& \eData(\mathtt{I}\: n) && = \eZ(n)\\ +& \eData(\mathtt{I}\: n) && = \eZ(n)\\ & \eData(\mathtt{B}\: s) && = \eBS(s). \end{alignat*} @@ -368,7 +368,7 @@ \section{Encoding and decoding \texttt{data}} \end{cases} $$ -\noindent +\noindent In the final case of $\ecTag$ we emit a head with major type 4 and argument 2. This indicates that an encoding of a list of length 2 will follow: the first element of the list is the constructor number and the second is the argument diff --git a/doc/plutus-core-spec/flat-serialisation.tex b/doc/plutus-core-spec/flat-serialisation.tex index 329e440b1f6..a323c2f0c48 100644 --- a/doc/plutus-core-spec/flat-serialisation.tex +++ b/doc/plutus-core-spec/flat-serialisation.tex @@ -86,7 +86,7 @@ \subsection{Padding} internal alignment (for example, to make sure that the contents of a bytestring are aligned on byte boundaries) and at the end of a complete encoding of a Plutus Core program to to make the length a multiple of 8 bits. -Symbolically, +Symbolically, $$ \pad(s) = s \cdot \pp{k} \quad \text{if $\length(s) = 8n+k$ with $n,k \in \N$ and $0 \leq k \leq 7$} $$ @@ -209,7 +209,7 @@ \subsection{Bytestrings} Bytestrings are encoded by dividing them into $$ \noindent -We define an encoder $\E_{C^*}$ for lists of chunks by +We define an encoder $\E_{C^*}$ for lists of chunks by $$ \E_{C^*} (s, [c_1, \ldots, c_n]) = s \cdot E_C(c_1) \cdot \cdots \cdot E_C(c_n) \cdot \bits{00000000}. $$ @@ -338,7 +338,7 @@ \subsection{Programs} \end{cases} $$ -\noindent +\noindent \subsection{Terms} Plutus Core terms are encoded by emitting a 4-bit tag identifying the type of @@ -476,7 +476,7 @@ \subsection{Built-in types} &\dtype(3 \cdot l) &&= (l, \ty{unit}) \\ &\dtype(4 \cdot l) &&= (l, \ty{bool}) \\ &\dtype([7,5] \cdot l) &&= (l', \listOf{t}) &&\quad \text{if $\dtype(l) = (l', t)$}\\ - &\dtype([7,7,6] \cdot l) &&= (l'', \pairOf{t_1}{t_2}) + &\dtype([7,7,6] \cdot l) &&= (l'', \pairOf{t_1}{t_2}) &&\ \begin{cases} \text{if} & \dtype(l) = (l', t_1)\\ \text{and} & \dtype(l') = (l'', t_2) @@ -540,7 +540,7 @@ \subsection{Constants} &\dConstant{\ty{bool}}(\bits{0} \cdot s) &&= (s, \texttt{False}) \\ &\dConstant{\ty{bool}}(\bits{1} \cdot s) &&= (s, \texttt{True}) \\ &\dConstant{\listOf{\tn}}(s) &&= \Dlist^{\tn}_{\mathsf{constant}}(s, l) \\ - &\dConstant{\pairOf{\tn_1}{\tn_2}}(s) &&= (s'', (c_1, c_2)) + &\dConstant{\pairOf{\tn_1}{\tn_2}}(s) &&= (s'', (c_1, c_2)) && \begin{cases} \text{if} & \dConstant{\tn_1}(s) = (s', c_1) \\ \text{and} & \dConstant{\tn_2}(s') = (s'', c_2) @@ -553,7 +553,7 @@ \subsection{Constants} \subsection{Built-in functions} Built-in functions are represented by seven-bit integer tags and encoded and decoded using $\E_7$ and $\D_7$. The tags are specified in -Tables~\ref{table:builtin-tags-batch-1}--\ref{table:builtin-tags-batch-5}. We +Tables~\ref{table:builtin-tags-batch-1}--\ref{table:builtin-tags-batch-6}. We assume that there are (partial) functions $\Tag$ and $\unTag$ which convert back and forth between builtin names and their tags. @@ -588,9 +588,9 @@ \subsection{Built-in functions} \TT{lessThanByteString} & $\bits{0010000}$ & 16 & \TT{unConstrData} & $\bits{0101010}$ & 42 \\ \TT{lessThanEqualsByteString} & $\bits{0010001}$ & 17 & \TT{unMapData} & $\bits{0101011}$ & 43 \\ \TT{sha2\_256} & $\bits{0010010}$ & 18 & \TT{unListData} & $\bits{0101100}$ & 44 \\ - \TT{sha3\_256} & $\bits{0010011}$ & 19 & \TT{unIData} & $\bits{0101101}$ & 45 \\ - \TT{blake2b\_256} & $\bits{0010100}$ & 20 & \TT{unBData} & $\bits{0101110}$ & 46 \\ - \TT{verifyEd25519Signature} & $\bits{0010101}$ & 21 & \TT{equalsData} & $\bits{0101111}$ & 47 \\ + \TT{sha3\_256} & $\bits{0010011}$ & 19 & \TT{unIData} & $\bits{0101101}$ & 45 \\ + \TT{blake2b\_256} & $\bits{0010100}$ & 20 & \TT{unBData} & $\bits{0101110}$ & 46 \\ + \TT{verifyEd25519Signature} & $\bits{0010101}$ & 21 & \TT{equalsData} & $\bits{0101111}$ & 47 \\ \TT{appendString} & $\bits{0010110}$ & 22 & \TT{mkPairData} & $\bits{0110000}$ & 48 \\ \TT{equalsString} & $\bits{0010111}$ & 23 & \TT{mkNilData} & $\bits{0110001}$ & 49 \\ \TT{encodeUtf8} & $\bits{0011000}$ & 24 & \TT{mkNilPairData} & $\bits{0110010}$ & 50 \\ @@ -663,7 +663,6 @@ \subsection{Built-in functions} \label{table:builtin-tags-batch-4} \end{table} - \begin{table}[H] \centering \begin{tabular}{|l|c|c|} @@ -689,10 +688,24 @@ \subsection{Built-in functions} \label{table:builtin-tags-batch-5} \end{table} +\begin{table}[H] +\centering +\begin{tabular}{|l|c|c|} + \hline + \Strut + Builtin & Binary & Decimal\\ + \hline + \TT{expModInteger} & $\bits{1010111}$ & 87 \\ +\hline +\end{tabular} +\caption{Tags for built-in functions (batch 6)} +\label{table:builtin-tags-batch-6} +\end{table} + \subsection{Variable names} Variable names are encoded and decoded using the $\Ename$ and $\Dname$ functions, and variables bound in \texttt{lam} expressions are encoded and -decoded by the $\Ebinder$ and $\Dbinder$ functions. +decoded by the $\Ebinder$ and $\Dbinder$ functions. \paragraph{De Bruijn indices.} We use serialised de Bruijn-indexed terms for script transmission because @@ -788,7 +801,7 @@ \section{Example} % remove it if the page breaks change. \begin{figure}[H] \centering - {\small + {\small \begin{Verbatim}[commandchars=\\\{\}] 00000101 : \textrm{Final integer chunk: \texttt{0000101} \arrow 5} 00000000 : \textrm{Final integer chunk: \texttt{0000000} \arrow 0} @@ -832,4 +845,3 @@ \section{Example} \caption{\texttt{flat} encoding of \texttt{index.uplc}} \label{fig:index-bytestring-example} \end{figure} - diff --git a/doc/plutus-core-spec/header.tex b/doc/plutus-core-spec/header.tex index 367e5a2f5b9..363d9a318a0 100644 --- a/doc/plutus-core-spec/header.tex +++ b/doc/plutus-core-spec/header.tex @@ -1,5 +1,5 @@ %% Stuff for index of notation -%% FYI, the nomencl package seems to discard entries containing '@' +%% FYI, the nomencl package seems to discard entries containing '@' \usepackage[intoc,refpage]{nomencl} \renewcommand{\nomname}{Index of Notation} \renewcommand{\pagedeclaration}[1]{,\ \ \hyperlink{page.#1}{\nobreakspace#1}} @@ -232,8 +232,8 @@ \newcommand{\unload}[1]{\mathcal{U}(#1)} \newcommand{\Unload}[2]{{#2}@{#1}} -\newcommand{\bcompute}{\color{blue}\compute} -\newcommand{\breturn}{\color{blue}\return} +\newcommand{\bcompute}{\color{blue}\compute} +\newcommand{\breturn}{\color{blue}\return} \newcommand{\bmapsto}{\color{blue}\mapsto} % This is to get blue symbols after an '&' inside an alignat % environment. It seems to mess up the spacing if you do anything @@ -317,7 +317,7 @@ %% NOTE!!! Probably \byte and \Z are only used in V1-builtins \newcommand{\kindstar}[1]{#1::\text{\textasteriskcentered}} % "v::*" (The ordinary * is a bit above the centreline) -\newcommand{\kindhash}[1]{#1::\text{\#}} % "v::#" +\newcommand{\kindhash}[1]{#1::\text{\#}} % "v::#" \newcommand\errorX{\textbf{\texttimes}} \newcommand\ValueOrError{\Inputs\disj\{\errorX\}} @@ -336,10 +336,10 @@ \DeclareMathOperator{\type}{\mathbf{\mathsf{type}}} \DeclareMathOperator{\length}{\ell} \DeclareMathOperator{\nextArg}{\mathsf{next}} -\DeclareMathOperator{\divfn}{div} -\DeclareMathOperator{\modfn}{mod} -\DeclareMathOperator{\quotfn}{quot} -\DeclareMathOperator{\remfn}{rem} +\DeclareMathOperator{\divfn}{\mathsf{div}} +\DeclareMathOperator{\modfn}{\mathsf{mod}} +\DeclareMathOperator{\quotfn}{\mathsf{quot}} +\DeclareMathOperator{\remfn}{\mathsf{rem}} \DeclareMathOperator{\inj}{inj} \DeclareMathOperator{\proj}{proj} \DeclareMathOperator{\is}{is} @@ -365,9 +365,9 @@ %% Macros for CBOR encoders and decoders -\newcommand\e{\mathcal{E}} +\newcommand\e{\mathcal{E}} \renewcommand\d{\mathcal{D}} %% This usually puts a dot under its argument - + \newcommand\eHead{\e_{\mathsf{head}}} \newcommand\dHead{\d_{\mathsf{head}}} diff --git a/doc/plutus-core-spec/notation.tex b/doc/plutus-core-spec/notation.tex index 7d21e19b13d..1230ad1634f 100644 --- a/doc/plutus-core-spec/notation.tex +++ b/doc/plutus-core-spec/notation.tex @@ -7,13 +7,13 @@ \subsection{Sets} \begin{itemize} \item The symbol $\disj$ denotes a disjoint union of sets; for emphasis we often use this to denote the union of sets which we know to be disjoint.% - \nomenclature[Azz]{$\disj$}{Disjoint union of sets}% + \nomenclature[Ayy]{$\disj$}{Disjoint union of sets}% \item Given a set $X$, $X^*$ denotes the set of finite sequences of elements of $X$: $$ X^*= \bigdisj{\{X^n: n \in \mathbb{N}\}}. $$% - \nomenclature[Azz]{$X^*$}{The set of all finite sequences of elements of a set $X$} + \nomenclature[Ayy]{$X^*$}{The set of all finite sequences of elements of a set $X$} \item $\N = \{0,1,2,3,\ldots\}$.% \nomenclature[An1]{$\N$}{$\{0,1,2,3,\ldots\}$} @@ -116,7 +116,7 @@ \subsection{Bytestrings and bitstrings} \item In the special case of bitstrings sometimes use notation such as \texttt{101110} to denote the list $[1,0,1,1,1,0]$; we use a teletype font to avoid confusion with decimal numbers. - + \item A bytestring can naturally be viewed as a bitstring whose length is a multiple of 8 simply by concatenating the bits of the individual bytes, and vice-versa (by breaking the bitstring into groups of 8 bits). To make this diff --git a/doc/plutus-core-spec/plutus-core-specification.bib b/doc/plutus-core-spec/plutus-core-specification.bib index e86b8460f70..6974b2beb48 100644 --- a/doc/plutus-core-spec/plutus-core-specification.bib +++ b/doc/plutus-core-spec/plutus-core-specification.bib @@ -46,7 +46,6 @@ @misc{CIP-0122 % url={https://cips.cardano.org/cips/cip0122/}, % howpublished={\url{https://cips.cardano.org/cips/cip0122/}} - @misc{CIP-0123, title={{Draft Cardano Improvement Proposal 0123 (CIP 0123) -- Bitwise operations over BuiltinByteString}}, url={https://github.com/cardano-foundation/CIPs/tree/master/CIP-0123}, @@ -115,8 +114,6 @@ @InProceedings{unravelling-recursion isbn="978-3-030-33636-3", doi=https://doi.org/10.1007/978-3-030-33636-3_15 } -%address=Cham, - @InProceedings{System-F-in-Agda, author="Chapman, James @@ -133,7 +130,6 @@ @InProceedings{System-F-in-Agda isbn="978-3-030-33636-3", doi=https://doi.org/10.1007/978-3-030-33636-3_10 } -%address="Cham", @misc{Agda, title="Agda", @@ -248,7 +244,6 @@ @book{Felleisen-Semantics-Engineering } - @article{Friedman-Lazy-Krivine, author = {Friedman, Daniel P. and Ghuloum, Abdulaziz and Siek, Jeremy G. and Winebarger, Onnie Lynn}, title = {Improving the {L}azy {K}rivine {M}achine}, @@ -267,7 +262,6 @@ @article{Friedman-Lazy-Krivine keywords = {Abstract machine, Call by need, Lambda calculus, Lazy evaluation}, } - @article{Felleisen-Hieb, author = {Felleisen, Matthias and Hieb, Robert}, title = {The Revised Report on the Syntactic Theories of Sequential Control and State}, @@ -285,7 +279,6 @@ @article{Felleisen-Hieb address = {Essex, UK}, } - @phdthesis{Girard-thesis, author = {Jean-Yves Girard}, title = {Interprétation fonctionnelle et élimination des @@ -329,7 +322,6 @@ @unpublished{Scott-encoding note = {Unpublished lecture notes} } - @inproceedings{Koopman:2014, author = {Koopman, Pieter and Plasmeijer, Rinus and Jansen, Jan Martin}, title = {Church Encoding of Data Types Considered Harmful for Implementations: Functional Pearl}, @@ -365,7 +357,6 @@ @article{Ahmed:2017 keywords = {dynamic typing, gradual typing, logical relation, parametricity}, } - @MISC{Geuvers-2014, author = {Geuvers, Herman}, title = {The {Church-Scott} representation of inductive and coinductive data}, @@ -373,7 +364,6 @@ @MISC{Geuvers-2014 howpublished = {Types 2014, Paris, Draft. \url{http://www.cs.ru.nl/~herman/PUBS/ChurchScottDataTypes.pdf}} } - % This appears to be the paper where the term "pattern functor" first appeared explicitly. @inproceedings{backhouseetal98, AUTHOR = "Backhouse, R. and Jansson, P. and Jeuring, J. and Meertens, L.", @@ -426,7 +416,6 @@ @inproceedings{Yakushev2009 keywords = {datatype-generic programming, fixed points, haskell, mutually recursive datatypes}, } - @article{Zahnentferner18-Chimeric, author = {Joachim Zahnentferner}, title = {Chimeric Ledgers: Translating and Unifying {UTxO}-based and Account-based @@ -441,7 +430,6 @@ @article{Zahnentferner18-Chimeric bibsource = {dblp computer science bibliography, https://dblp.org} } - @article{Zahnentferner18-UTxO, author = {Joachim Zahnentferner}, title = {An Abstract Model of UTxO-based Cryptocurrencies with Scripts}, @@ -455,7 +443,6 @@ @article{Zahnentferner18-UTxO bibsource = {dblp computer science bibliography, https://dblp.org} } - @inproceedings{ches-2011-24091, title={High-Speed High-Security Signatures}, booktitle={CHES}, @@ -469,7 +456,6 @@ @inproceedings{ches-2011-24091 year=2011 } - @misc{flat, title="Flat format specification", author={Pasqualino `Titto' Assini}, @@ -490,7 +476,6 @@ @misc{rfc8949-CBOR month = dec } - @article{Plotkin-cbn-cbv, author = {Gordon D. Plotkin}, title = {Call-by-Name, Call-by-Value and the lambda-Calculus}, @@ -506,14 +491,12 @@ @article{Plotkin-cbn-cbv bibsource = {dblp computer science bibliography, https://dblp.org} } - @MISC{Felleisen-pllc, author = {Matthias Felleisen}, title = {Programming languages and lambda calculi}, year = {2007} } - @book{Barendregt, author = {Hendrik Pieter Barendregt}, title = {The Lambda Calculus - its Syntax and Semantics}, @@ -526,7 +509,6 @@ @book{Barendregt bibsource = {dblp computer science bibliography, https://dblp.org} } - @article{deBruijn, title = {Lambda calculus notation with nameless dummies, a tool for automatic formula manipulation, with application to the {Church-Rosser} @@ -562,17 +544,15 @@ @misc{SECP256 year=2010 } - @misc{BIP-146, title={{Bitcoin Improvement Proposal 146: Dealing with signature encoding malleability}}, -author={Johnson Lau and Pieter Wuilie}, +author={Johnson Lau and Pieter Wuille}, url={https://github.com/bitcoin/bips/blob/master/bip-0146.mediawiki}, howpublished={\url{https://github.com/bitcoin/bips/blob/master/bip-0146.mediawiki}}, year=2016 } https://github.com/bitcoin/bips/blob/master/bip-0146.mediawiki#LOW_S - @misc{BIP-340, title={{Bitcoin Improvement Proposal 340: Schnorr Signatures for secp256k1}}, author={Johnson Lau and Jonas Nick and Tim Ruffing}, @@ -602,7 +582,6 @@ @misc{Bitcoin-ECDSA year=2022 } - @TECHREPORT{Johnson-Menezes-ECDSA-techreport, author = {Don Johnson and Alfred Menezes}, title = {{The Elliptic Curve Digital Signature Algorithm (ECDSA)}}, @@ -631,7 +610,6 @@ @misc{rfc8032-EdDSA } % See also https://tools.ietf.org/id/draft-irtf-cfrg-eddsa-05.html - @article{Johnson-Menezes-Vanstone-ECDSA, author = {Don Johnson and Alfred Menezes and Scott A. Vanstone}, title = {The Elliptic Curve Digital Signature Algorithm {(ECDSA)}}, @@ -668,7 +646,6 @@ @inproceedings{Schnorr89 year = 1989 } - @misc{Unicode-standard, title={{The Unicode Standard}}, author={{The Unicode Consortium}}, @@ -690,7 +667,6 @@ @misc{CBOR-notable-tags howpublished={\url{https://www.ietf.org/archive/id/draft-bormann-cbor-notable-tags-06.html}} } - @book{Silverman-Arithmetic-EC, author = "Silverman, Joseph H", title = "{The Arithmetic of Elliptic Curves}", @@ -738,7 +714,6 @@ @misc{BLST-library howpublished={\url{https://github.com/supranational/blst}} } - @misc{Costello-pairings, title={Pairings for Beginners}, author={Craig Costello}, @@ -804,8 +779,6 @@ @misc{IETF-Blake2 abstract = {This document describes the cryptographic hash function BLAKE2 and makes the algorithm specification and C source code conveniently available to the Internet community. BLAKE2 comes in two main flavors: BLAKE2b is optimized for 64-bit platforms and BLAKE2s for smaller architectures. BLAKE2 can be directly keyed, making it functionally equivalent to a Message Authentication Code (MAC).}, } - - @misc{KeccakRef3, author = {G. Bertoni and J. Daemen and M. Peeters and G. Van Assche}, title = {{The Keccak Reference}}, @@ -834,3 +807,13 @@ @misc{ripemd-2 howpublished = {\url{https://homes.esat.kuleuven.be/~bosselae/ripemd160.html}}, year={2012} } + +@book{Koblitz-GTM, + author = {Koblitz, Neal}, + title = "{A Course in Number Theory and Cryptography}", + publisher = "Springer-Verlag", + series = {Graduate Texts in Mathematics}, + volume = 114, + edition = {2nd}, + year = "1994" +} diff --git a/doc/plutus-core-spec/plutus-core-specification.tex b/doc/plutus-core-spec/plutus-core-specification.tex index f4d78c4c615..52d6735d242 100644 --- a/doc/plutus-core-spec/plutus-core-specification.tex +++ b/doc/plutus-core-spec/plutus-core-specification.tex @@ -6,7 +6,7 @@ \LARGE{\red{\textsf{DRAFT}}} } -\date{10th September 2024} +\date{1st November 2024} \author{Plutus Core Team} \input{header.tex} @@ -21,7 +21,7 @@ the built-in types and functions. The Appendices include a list of supported builtins in each era and some aspects of Plutus Core which have been mechanically formalised. - + This document only describes untyped Plutus Core: a subsequent version will also include the syntax and semantics of Typed Plutus Core and describe its relation to untyped Plutus Core. diff --git a/doc/plutus-core-spec/untyped-cek-machine.tex b/doc/plutus-core-spec/untyped-cek-machine.tex index 057d814b62a..3b381d0c84e 100644 --- a/doc/plutus-core-spec/untyped-cek-machine.tex +++ b/doc/plutus-core-spec/untyped-cek-machine.tex @@ -39,7 +39,7 @@ \section{The CEK machine} &&& | \enspace \VConstr{i}{\repetition{V}} \enspace | \enspace \VBuiltin{b}{\repetition{V}}{\eta}\\ \textrm{Environment} & \rho & ::= & [] \enspace | \enspace \rho[x \mapsto V] \\ \textrm{Expected builtin arguments} & \eta & ::= & [\iota] \enspace | \enspace \iota \cons \eta\\ - \end{array}\] + \end{array}\] \caption{Grammar of CEK machine states for Plutus Core} \label{fig:untyped-cek-states} \end{figure}% @@ -72,7 +72,7 @@ \section{The CEK machine} \in \Fun$. This means that we can never have an empty $\eta$ in $\VBuiltin{b}{\repetition{V}}{\eta}$, which isn't entirely obvious. We'll have to revisit this if we ever have nullary builtins.} - + \kwxm{Do we need to insist that CEK-values are well-formed, for example that there are enough variables in the environments to yield closed terms and that in $\VBuiltin{b}{\repetition{V}}{\eta}$ $\eta$ is a suffix of $\arity{b}$? @@ -205,7 +205,7 @@ \subsection{Converting CEK evaluation results into Plutus Core terms} \begin{figure}[H] \centering - + \begin{subfigure}[b]{\textwidth} \begin{align*} \unload{\VCon{\tn}{c}} &= \con{\tn}{c}\\ @@ -227,7 +227,7 @@ \subsection{Converting CEK evaluation results into Plutus Core terms} \caption{Discharging CEK values} \label{fig:discharge-val} \end{subfigure} - + \begin{subfigure}[c]{\textwidth} \begin{align*} \Unload{\rho}{M} &= [(\unload{V_1})/x_1]\cdots[(\unload{V_n})/x_n]M \quad @@ -236,7 +236,7 @@ \subsection{Converting CEK evaluation results into Plutus Core terms} \caption{Iterated substitution/discharging} \label{fig:discharge-env} \end{subfigure} - + \caption{Discharging CEK values to obtain Plutus Core terms} \label{fig:discharge-cek-val} \end{figure}% diff --git a/doc/plutus-core-spec/untyped-grammar.tex b/doc/plutus-core-spec/untyped-grammar.tex index 224fad973f4..67a59170fd2 100644 --- a/doc/plutus-core-spec/untyped-grammar.tex +++ b/doc/plutus-core-spec/untyped-grammar.tex @@ -40,10 +40,10 @@ \subsection{Lexical grammar} % @sqs = ' ( ($printable # ['\\]) | (\\$printable) )* ' -% +% % -- A double quoted string, allowing escaped characters including \". Similar to @sqs % @dqs = \" ( ($printable # [\"\\]) | (\\$printable) )* \" -% +% % -- A sequence of printable characters not containing '(' or ')' such that the % -- first character is not a space or a single or double quote. If there are any % -- further characters then they must comprise a sequence of printable characters @@ -52,7 +52,7 @@ \subsection{Lexical grammar} % -- below. % $nonparen = $printable # [\(\)] % @chars = ($nonparen # ['\"$white]) ($nonparen* ($nonparen # $white))? -% +% % "()" | @sqs | @dqs | @chars { tok (\p s -> alex $ TkLiteralConst p (textOf s)) `andBegin` 0 } %% "()" diff --git a/doc/plutus-core-spec/untyped-reduction.tex b/doc/plutus-core-spec/untyped-reduction.tex index 5f07f58deab..138e15e774a 100644 --- a/doc/plutus-core-spec/untyped-reduction.tex +++ b/doc/plutus-core-spec/untyped-reduction.tex @@ -37,7 +37,7 @@ \subsection{Term reduction} I'm somewhat tempted to dump this in favour of SOS.} \kwxm{Do we need a uniqueness condition on names somewhere?} - + We define the semantics of Plutus Core using contextual semantics (or reduction semantics): see~\cite{Felleisen-Hieb} or~\cite{Felleisen-Semantics-Engineering} or~\cite[5.3]{Harper:PFPL}, for example. We use $A$ to denote a partial @@ -135,7 +135,7 @@ \subsection{Term reduction} \BinaryInfC{$\step{\force{A}}{A}$} \end{prooftree} -% \hfill\begin{minipage}{0.3\linewidth} +% \hfill\begin{minipage}{0.3\linewidth} \begin{prooftree} \AxiomC{} % If we're putting these side by side we need \strut here to get rules aligned % \RightLabel{\textsf{error}} @@ -188,5 +188,5 @@ \subsection{Term reduction} \textit{do} need special rules for the final argument because if $M \in A$ we have to look at $b$ to make sure that the final argument (or force) is the right kind of thing.} - - + + diff --git a/doc/plutus-core-spec/untyped-values.tex b/doc/plutus-core-spec/untyped-values.tex index 39495ad0b9a..a54279877ec 100644 --- a/doc/plutus-core-spec/untyped-values.tex +++ b/doc/plutus-core-spec/untyped-values.tex @@ -51,7 +51,7 @@ \subsection{Values in Plutus Core} \medskip \noindent We let $\pbas$ denote the set of terms generated by the grammar -in Figure~\ref{fig:partial-applications} and +in Figure~\ref{fig:partial-applications} and we define a function $\beta$ which extracts the name of the built-in function occurring in a term in $\pbas$: $$ @@ -100,7 +100,7 @@ \subsection{Values in Plutus Core} %% $$ %% \noindent This is well defined because of our assumption that the sets $\Con{\tn}$ are disjoint. %% \item We also define a partial order $\preceq$ on the set $\Uni^{\top}$ by -%% $t_1 \preceq t_2$ if $t_1 = t_2$ or $t_2 = \top$. +%% $t_1 \preceq t_2$ if $t_1 = t_2$ or $t_2 = \top$. \paragraph{Well-formed partial applications.} A term $\pba \in \pbas$ is diff --git a/plutus-benchmark/script-contexts/src/PlutusBenchmark/ScriptContexts.hs b/plutus-benchmark/script-contexts/src/PlutusBenchmark/ScriptContexts.hs index 479b75e3689..ed641da725d 100644 --- a/plutus-benchmark/script-contexts/src/PlutusBenchmark/ScriptContexts.hs +++ b/plutus-benchmark/script-contexts/src/PlutusBenchmark/ScriptContexts.hs @@ -9,7 +9,7 @@ import PlutusLedgerApi.V1.Address import PlutusLedgerApi.V1.Value import PlutusLedgerApi.V3 (OutputDatum (NoOutputDatum), PubKeyHash (..), Redeemer (..), ScriptContext (..), ScriptInfo (SpendingScript), TxId (..), TxInfo (..), - TxOut (..), TxOutRef (..), always) + TxOut (..), TxOutRef (..), always, emptyMintValue) import PlutusTx qualified import PlutusTx.AssocMap qualified as Map import PlutusTx.Builtins qualified as PlutusTx @@ -32,7 +32,7 @@ mkTxInfo i = TxInfo { txInfoReferenceInputs=mempty, txInfoOutputs=fmap mkTxOut [1..i], txInfoFee=10000, - txInfoMint=mempty, + txInfoMint=emptyMintValue, txInfoTxCerts=mempty, txInfoWdrl=Map.empty, txInfoValidRange=always, diff --git a/plutus-benchmark/script-contexts/test/9.6/checkScriptContext1-20.budget.golden b/plutus-benchmark/script-contexts/test/9.6/checkScriptContext1-20.budget.golden index 853f70358f8..4df6ef26a00 100644 --- a/plutus-benchmark/script-contexts/test/9.6/checkScriptContext1-20.budget.golden +++ b/plutus-benchmark/script-contexts/test/9.6/checkScriptContext1-20.budget.golden @@ -1,2 +1,2 @@ -({cpu: 11100264187581 -| mem: 11100001066437}) \ No newline at end of file +({cpu: 11100263419581 +| mem: 11100001061637}) \ No newline at end of file diff --git a/plutus-benchmark/script-contexts/test/9.6/checkScriptContext1-4.budget.golden b/plutus-benchmark/script-contexts/test/9.6/checkScriptContext1-4.budget.golden index 91815276ecc..779e93ab6dd 100644 --- a/plutus-benchmark/script-contexts/test/9.6/checkScriptContext1-4.budget.golden +++ b/plutus-benchmark/script-contexts/test/9.6/checkScriptContext1-4.budget.golden @@ -1,2 +1,2 @@ -({cpu: 3100079463709 -| mem: 3100000324645}) \ No newline at end of file +({cpu: 3100079207709 +| mem: 3100000323045}) \ No newline at end of file diff --git a/plutus-benchmark/script-contexts/test/9.6/checkScriptContext1.pir.golden b/plutus-benchmark/script-contexts/test/9.6/checkScriptContext1.pir.golden index 81906b60cf2..715e0ef6d50 100644 --- a/plutus-benchmark/script-contexts/test/9.6/checkScriptContext1.pir.golden +++ b/plutus-benchmark/script-contexts/test/9.6/checkScriptContext1.pir.golden @@ -778,13 +778,6 @@ (go xs)) in let - ~`$fUnsafeFromDataValue` : - data -> (\k v -> List (Tuple2 k v)) bytestring integer - = `$fUnsafeFromDataMap_$cunsafeFromBuiltinData` - {bytestring} - {integer} - unBData - unIData !`$fUnsafeFromDataTxOut_$cunsafeFromBuiltinData` : data -> TxOut = \(eta : data) -> @@ -866,7 +859,11 @@ {bytestring} {(\k v -> List (Tuple2 k v)) bytestring integer} unBData - `$fUnsafeFromDataValue` + (`$fUnsafeFromDataMap_$cunsafeFromBuiltinData` + {bytestring} + {integer} + unBData + unIData) (headList {data} l)) (let !tup : pair integer (list data) @@ -1179,7 +1176,11 @@ {bytestring} {(\k v -> List (Tuple2 k v)) bytestring integer} unBData - `$fUnsafeFromDataValue` + (`$fUnsafeFromDataMap_$cunsafeFromBuiltinData` + {bytestring} + {integer} + unBData + unIData) (headList {data} l)) (let !d : data = headList {data} l diff --git a/plutus-benchmark/script-contexts/test/9.6/checkScriptContext1.size.golden b/plutus-benchmark/script-contexts/test/9.6/checkScriptContext1.size.golden index 6496f603eb9..f8035a6b440 100644 --- a/plutus-benchmark/script-contexts/test/9.6/checkScriptContext1.size.golden +++ b/plutus-benchmark/script-contexts/test/9.6/checkScriptContext1.size.golden @@ -1 +1 @@ -3221 \ No newline at end of file +3218 \ No newline at end of file diff --git a/plutus-benchmark/script-contexts/test/9.6/checkScriptContext2-20.budget.golden b/plutus-benchmark/script-contexts/test/9.6/checkScriptContext2-20.budget.golden index 93d4a85de53..32dca36b004 100644 --- a/plutus-benchmark/script-contexts/test/9.6/checkScriptContext2-20.budget.golden +++ b/plutus-benchmark/script-contexts/test/9.6/checkScriptContext2-20.budget.golden @@ -1,2 +1,2 @@ -({cpu: 11100253887109 -| mem: 11100001016294}) \ No newline at end of file +({cpu: 11100253119109 +| mem: 11100001011494}) \ No newline at end of file diff --git a/plutus-benchmark/script-contexts/test/9.6/checkScriptContext2-4.budget.golden b/plutus-benchmark/script-contexts/test/9.6/checkScriptContext2-4.budget.golden index 1890a0031f0..29fec21fcb6 100644 --- a/plutus-benchmark/script-contexts/test/9.6/checkScriptContext2-4.budget.golden +++ b/plutus-benchmark/script-contexts/test/9.6/checkScriptContext2-4.budget.golden @@ -1,2 +1,2 @@ -({cpu: 3100076414565 -| mem: 3100000309734}) \ No newline at end of file +({cpu: 3100076158565 +| mem: 3100000308134}) \ No newline at end of file diff --git a/plutus-benchmark/script-contexts/test/9.6/checkScriptContext2.pir.golden b/plutus-benchmark/script-contexts/test/9.6/checkScriptContext2.pir.golden index 9d69fe6b4ce..3cfe475670e 100644 --- a/plutus-benchmark/script-contexts/test/9.6/checkScriptContext2.pir.golden +++ b/plutus-benchmark/script-contexts/test/9.6/checkScriptContext2.pir.golden @@ -747,13 +747,6 @@ (go xs)) in let - ~`$fUnsafeFromDataValue` : - data -> (\k v -> List (Tuple2 k v)) bytestring integer - = `$fUnsafeFromDataMap_$cunsafeFromBuiltinData` - {bytestring} - {integer} - unBData - unIData data StakingCredential | StakingCredential_match where StakingHash : Credential -> StakingCredential StakingPtr : integer -> integer -> integer -> StakingCredential @@ -853,7 +846,11 @@ {bytestring} {(\k v -> List (Tuple2 k v)) bytestring integer} unBData - `$fUnsafeFromDataValue` + (`$fUnsafeFromDataMap_$cunsafeFromBuiltinData` + {bytestring} + {integer} + unBData + unIData) (headList {data} l)) (let !tup : pair integer (list data) @@ -1168,7 +1165,11 @@ {bytestring} {(\k v -> List (Tuple2 k v)) bytestring integer} unBData - `$fUnsafeFromDataValue` + (`$fUnsafeFromDataMap_$cunsafeFromBuiltinData` + {bytestring} + {integer} + unBData + unIData) (headList {data} l)) (let !d : data = headList {data} l diff --git a/plutus-benchmark/script-contexts/test/9.6/checkScriptContext2.size.golden b/plutus-benchmark/script-contexts/test/9.6/checkScriptContext2.size.golden index 50e9648605c..79aafa0e780 100644 --- a/plutus-benchmark/script-contexts/test/9.6/checkScriptContext2.size.golden +++ b/plutus-benchmark/script-contexts/test/9.6/checkScriptContext2.size.golden @@ -1 +1 @@ -3157 \ No newline at end of file +3154 \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/README.md b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/README.md new file mode 100644 index 00000000000..e9fdf93760c --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/README.md @@ -0,0 +1,64 @@ +### Test vectors for `verifyEcdsaSecp256k1Signature` + +Most of the `test-vector-*` test case have been generated using `OpenSSL +3.0.14.4` using the following procedure. + + 1. Type `openssl ecparam -name secp256k1 -outform DER -out secp256k1.der` to generate the `secp256k1` elliptic curve parameters and store them in the file `secp256k1.der` + + 2. Type `openssl ecparam -in secp256k1.der -inform DER -genkey -noout -outform DER -out pk.der` + to generate a keypair and store it in the file `pk.der` + + 3. Type `openssl ec -in pk.der -outform DER -pubout -conv_form compressed -out vk.der` to + generate a compressed verification key (ie public key) and store it in the file `vk.der`. + + 4. Given a message in `msg.txt`, generate a signature for the SHA2-256 hash + of the message using the private key generated earlier using `openssl + dgst-sha2-256 -sign pk.der msg.txt > sig.txt`. Use `-sha3-256` instead + to sign the SHA3-256 hash of the message. The signature will be stored in + DER-encoded binary form. The ECDSA algorithm involves a random number `k` + which is generated anew for each signature, and each value of `k` produces + a different signature, so repeating this step will (with very high + probabilty) generate a different signature every time: all of these are + valid signatures for the given keypair and message. + + 5. Look at the contents of `sig.txt` using `dumpasn1 sig.txt`. This will produce output similar + to that below. + + ``` + 0 69: SEQUENCE { + 2 32: INTEGER + : 50 F1 64 A7 F6 50 91 4B 3B 7A 25 88 BE 77 54 E5 + : 62 EB 6F 93 E8 31 B9 84 29 69 31 62 8C 86 C5 23 + 36 33: INTEGER + : 00 9B 5A 92 ED 21 5D 95 82 3E FD 2C 6F A7 10 40 + : 66 DF 0F D3 3D 19 14 EC 9A C8 73 BB 27 D6 2B 11 + : 0E + : } +``` + + 6. The first `INTEGER` entry in the output above is the `r` component of the + signature, the second is the `s` component. The two numbers at the start + of the `INTEGER` lines are the offset of the `INTEGER` object within the + file and the object's length, which will probably be 32 or 33 for + Secp256k1. If the second entry has length 33 (as in this case) the + signature is a "high s" signature which is accepted by OpenSSL but not by + `verifyEcdsaSecp256k1Signature` (following + [Bitcoin](https://github.com/bitcoin/bips/blob/master/bip-0146.mediawiki#low_s); + see also Section 4.3.3.1 of the Plutus Core specification) . If this + happens, discard the signature and generate a new signature until you get + one whose `s` component has length 32. + + 7. If the first entry has length 32, concatenate the hex digits with those of the second entry to + obtain a bytestring of length 64. If the first entry has length 33, the first byte will be 00. + Delete this and proceed as in the length 32 case. + + 8. Create a Plutus script applying `verifyEcdsaSecp256k1Signature` to + * A hex string containing the verification key: you can get this by typing + `dumpasn1 -20 -p -a vk.der | grep -v BIT | tr -d '\n' | sed 's/ //g' | tr A-Z a-z`. + * The relevant hash function (`sha2_256` or `sha3_256`) applied to a hex dump of the `msg.txt` + file, for example obtained by `xxd -p msg.txt` + * The hex string obtained in Step 7 (this is the signature) + + 9. The process can be repeated for the same keypair and message by going back to Step 4, or you + can start again with a new keypair and/or message. + diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-01/test-vector-01.uplc b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-01/test-vector-01.uplc new file mode 100644 index 00000000000..2dd9731eabf --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-01/test-vector-01.uplc @@ -0,0 +1,16 @@ +-- Generated using OpenSSL 3.0.14.4 +-- Signing key a1adc24fc72eeb3ca032f68134a21c83dbebed4d7088a3794dbe65b4570604fd +-- Low r, low s signature +-- Expect True +(program 1.0.0 + [ + [ + [ + (builtin verifyEcdsaSecp256k1Signature) + (con bytestring #032e433589dce61863199171f4d1e3fa946a5832621fcd29559940a0950f96fb6f) + ] + [(builtin sha2_256) (con bytestring #)] + ] + (con bytestring #4941155e2303988a1be97a021fbaf9fe6064d05ea694bc5e89328f297154e5c63a2f3e7b5f509294a4c2e22feb697a16b792fabfebe9d0f38403b1c929836b5a) + ] +) diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-01/test-vector-01.uplc.budget.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-01/test-vector-01.uplc.budget.expected new file mode 100644 index 00000000000..961b1c22b98 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-01/test-vector-01.uplc.budget.expected @@ -0,0 +1,2 @@ +({cpu: 43490883 +| mem: 1014}) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-01/test-vector-01.uplc.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-01/test-vector-01.uplc.expected new file mode 100644 index 00000000000..3760fc7a698 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-01/test-vector-01.uplc.expected @@ -0,0 +1 @@ +(program 1.0.0 (con bool True)) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-02/test-vector-02.uplc b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-02/test-vector-02.uplc new file mode 100644 index 00000000000..d8314d6eec7 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-02/test-vector-02.uplc @@ -0,0 +1,16 @@ +-- Generated using OpenSSL 3.0.14.4 +-- Signing key a1adc24fc72eeb3ca032f68134a21c83dbebed4d7088a3794dbe65b4570604fd +-- Same keypair and message as test-vector-01, alternative signature (high r, low s) +-- Expect True +(program 1.0.0 + [ + [ + [ + (builtin verifyEcdsaSecp256k1Signature) + (con bytestring #032e433589dce61863199171f4d1e3fa946a5832621fcd29559940a0950f96fb6f) + ] + [(builtin sha2_256) (con bytestring #)] + ] + (con bytestring #ccfd8a4781b4d69121727222f062d2c77e97496e1c701d3a0abd840207e6dcd1016c0ee3d92f1eec1ca335ec3eb285612fb82ee2c1d1f80e706b2e907dc60cc4) + ] +) diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-02/test-vector-02.uplc.budget.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-02/test-vector-02.uplc.budget.expected new file mode 100644 index 00000000000..961b1c22b98 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-02/test-vector-02.uplc.budget.expected @@ -0,0 +1,2 @@ +({cpu: 43490883 +| mem: 1014}) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-02/test-vector-02.uplc.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-02/test-vector-02.uplc.expected new file mode 100644 index 00000000000..3760fc7a698 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-02/test-vector-02.uplc.expected @@ -0,0 +1 @@ +(program 1.0.0 (con bool True)) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-03/test-vector-03.uplc b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-03/test-vector-03.uplc new file mode 100644 index 00000000000..c5b188845ba --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-03/test-vector-03.uplc @@ -0,0 +1,17 @@ +-- Generated using OpenSSL 3.0.14.4 +-- Signing key a1adc24fc72eeb3ca032f68134a21c83dbebed4d7088a3794dbe65b4570604fd +-- Same keypair and message as test-vector-01, alternative signature (low r, high s) +-- Expect False (we don't accept signatures with high s components) +(program 1.0.0 + [ + [ + [ + (builtin verifyEcdsaSecp256k1Signature) + (con bytestring #032e433589dce61863199171f4d1e3fa946a5832621fcd29559940a0950f96fb6f) + ] + [(builtin sha2_256) (con bytestring #)] + ] + (con bytestring #603e6e7bf67152188204f76f6274d38c477bdbc3954cdaa44e4ef49691a517ded5eaad30c2e69e3e9b124bcc48fa0e4d0aa0dfdb4ca9d537ea1dcd46c94b8f56 + ) + ] +) diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-03/test-vector-03.uplc.budget.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-03/test-vector-03.uplc.budget.expected new file mode 100644 index 00000000000..961b1c22b98 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-03/test-vector-03.uplc.budget.expected @@ -0,0 +1,2 @@ +({cpu: 43490883 +| mem: 1014}) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-03/test-vector-03.uplc.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-03/test-vector-03.uplc.expected new file mode 100644 index 00000000000..3ee9f07f31d --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-03/test-vector-03.uplc.expected @@ -0,0 +1 @@ +(program 1.0.0 (con bool False)) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-04/test-vector-04.uplc b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-04/test-vector-04.uplc new file mode 100644 index 00000000000..7683f197b5a --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-04/test-vector-04.uplc @@ -0,0 +1,16 @@ +-- Generated using OpenSSL 3.0.14.4 +-- Signing key a1adc24fc72eeb3ca032f68134a21c83dbebed4d7088a3794dbe65b4570604fd +-- Same keypair and message as test-vector-01, low-s version of signature in test-vector-03 +-- Expect True +(program 1.0.0 + [ + [ + [ + (builtin verifyEcdsaSecp256k1Signature) + (con bytestring #032e433589dce61863199171f4d1e3fa946a5832621fcd29559940a0950f96fb6f) + ] + [(builtin sha2_256) (con bytestring #)] + ] + (con bytestring #603e6e7bf67152188204f76f6274d38c477bdbc3954cdaa44e4ef49691a517de2a1552cf3d1961c164edb433b705f1b1b00dfd0b629ecb03d5b4914606eab1eb) + ] +) diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-04/test-vector-04.uplc.budget.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-04/test-vector-04.uplc.budget.expected new file mode 100644 index 00000000000..961b1c22b98 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-04/test-vector-04.uplc.budget.expected @@ -0,0 +1,2 @@ +({cpu: 43490883 +| mem: 1014}) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-04/test-vector-04.uplc.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-04/test-vector-04.uplc.expected new file mode 100644 index 00000000000..3760fc7a698 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-04/test-vector-04.uplc.expected @@ -0,0 +1 @@ +(program 1.0.0 (con bool True)) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-05/test-vector-05.uplc b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-05/test-vector-05.uplc new file mode 100644 index 00000000000..9558a4998e8 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-05/test-vector-05.uplc @@ -0,0 +1,16 @@ +-- Generated using OpenSSL 3.0.14.4 +-- Signing key a1adc24fc72eeb3ca032f68134a21c83dbebed4d7088a3794dbe65b4570604fd +-- Same keypair and message as test-vector-01, sha3_256 instead of sha2_256 +-- Expect True +(program 1.0.0 + [ + [ + [ + (builtin verifyEcdsaSecp256k1Signature) + (con bytestring #032e433589dce61863199171f4d1e3fa946a5832621fcd29559940a0950f96fb6f) + ] + [(builtin sha3_256) (con bytestring #)] + ] + (con bytestring #5958fe71b4498446de57d0416ab8c41155fc16d46844fbc3fc9898bfca6badf9777d01c5b74b002678bfe904e941c096b5faf613a37b4d518e0ca750abcfa020) + ] +) diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-05/test-vector-05.uplc.budget.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-05/test-vector-05.uplc.budget.expected new file mode 100644 index 00000000000..dae7418fe2f --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-05/test-vector-05.uplc.budget.expected @@ -0,0 +1,2 @@ +({cpu: 44719534 +| mem: 1014}) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-05/test-vector-05.uplc.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-05/test-vector-05.uplc.expected new file mode 100644 index 00000000000..3760fc7a698 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-05/test-vector-05.uplc.expected @@ -0,0 +1 @@ +(program 1.0.0 (con bool True)) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-06/test-vector-06.uplc b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-06/test-vector-06.uplc new file mode 100644 index 00000000000..0bf5eee7cac --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-06/test-vector-06.uplc @@ -0,0 +1,16 @@ +-- Generated using OpenSSL 3.0.14.4 +-- Signing key a1adc24fc72eeb3ca032f68134a21c83dbebed4d7088a3794dbe65b4570604fd +-- Same keypair and message as test-vector-01, sha3_256 instead of sha2_256, alternative signature +-- Expect True +(program 1.0.0 + [ + [ + [ + (builtin verifyEcdsaSecp256k1Signature) + (con bytestring #032e433589dce61863199171f4d1e3fa946a5832621fcd29559940a0950f96fb6f) + ] + [(builtin sha3_256) (con bytestring #)] + ] + (con bytestring #d7086f9d50c7bbdd739c16da7d16bbabff5b58fc982013c9bac6df7a7200e3fe496c38ef025c3adf1cd060e0a74112580d9d2226213d7e70f0eee726c484e986) + ] +) diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-06/test-vector-06.uplc.budget.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-06/test-vector-06.uplc.budget.expected new file mode 100644 index 00000000000..dae7418fe2f --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-06/test-vector-06.uplc.budget.expected @@ -0,0 +1,2 @@ +({cpu: 44719534 +| mem: 1014}) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-06/test-vector-06.uplc.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-06/test-vector-06.uplc.expected new file mode 100644 index 00000000000..3760fc7a698 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-06/test-vector-06.uplc.expected @@ -0,0 +1 @@ +(program 1.0.0 (con bool True)) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-07/test-vector-07.uplc b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-07/test-vector-07.uplc new file mode 100644 index 00000000000..08b77f4b161 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-07/test-vector-07.uplc @@ -0,0 +1,16 @@ +-- Generated using OpenSSL 3.0.14.4 +-- Signing key a1adc24fc72eeb3ca032f68134a21c83dbebed4d7088a3794dbe65b4570604fd +-- Same keypair and signature as test-vector-01, different message +-- Expect False +(program 1.0.0 + [ + [ + [ + (builtin verifyEcdsaSecp256k1Signature) + (con bytestring #032e433589dce61863199171f4d1e3fa946a5832621fcd29559940a0950f96fb6f) + ] + [(builtin sha2_256) (con bytestring #48656c6c6f210a)] + ] + (con bytestring #4941155e2303988a1be97a021fbaf9fe6064d05ea694bc5e89328f297154e5c63a2f3e7b5f509294a4c2e22feb697a16b792fabfebe9d0f38403b1c929836b5a) + ] +) diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-07/test-vector-07.uplc.budget.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-07/test-vector-07.uplc.budget.expected new file mode 100644 index 00000000000..961b1c22b98 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-07/test-vector-07.uplc.budget.expected @@ -0,0 +1,2 @@ +({cpu: 43490883 +| mem: 1014}) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-07/test-vector-07.uplc.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-07/test-vector-07.uplc.expected new file mode 100644 index 00000000000..3ee9f07f31d --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-07/test-vector-07.uplc.expected @@ -0,0 +1 @@ +(program 1.0.0 (con bool False)) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-08/test-vector-08.uplc b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-08/test-vector-08.uplc new file mode 100644 index 00000000000..f94402a99e8 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-08/test-vector-08.uplc @@ -0,0 +1,16 @@ +-- Generated using OpenSSL 3.0.14.4 +-- Signing key a1adc24fc72eeb3ca032f68134a21c83dbebed4d7088a3794dbe65b4570604fd +-- Same keypair as test-vector-01, different message with correct signature +-- Expect True +(program 1.0.0 + [ + [ + [ + (builtin verifyEcdsaSecp256k1Signature) + (con bytestring #032e433589dce61863199171f4d1e3fa946a5832621fcd29559940a0950f96fb6f) + ] + [(builtin sha2_256) (con bytestring #48656c6c6f210a)] + ] + (con bytestring #3499b841ac6eeb300b0dc9ed50e9c196d2b74f1745540f120bf603c48189b0ee6c48eacc04f2c3d3095fa17e11cc3b7642331963d52a9177d0d0685c4b3ff17f) + ] +) diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-08/test-vector-08.uplc.budget.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-08/test-vector-08.uplc.budget.expected new file mode 100644 index 00000000000..961b1c22b98 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-08/test-vector-08.uplc.budget.expected @@ -0,0 +1,2 @@ +({cpu: 43490883 +| mem: 1014}) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-08/test-vector-08.uplc.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-08/test-vector-08.uplc.expected new file mode 100644 index 00000000000..3760fc7a698 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-08/test-vector-08.uplc.expected @@ -0,0 +1 @@ +(program 1.0.0 (con bool True)) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-09/test-vector-09.uplc b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-09/test-vector-09.uplc new file mode 100644 index 00000000000..136e4e01c2c --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-09/test-vector-09.uplc @@ -0,0 +1,16 @@ +-- Generated using OpenSSL 3.0.14.4 +-- Signing key a1adc24fc72eeb3ca032f68134a21c83dbebed4d7088a3794dbe65b4570604fd +-- Same keypair as test-vector-01, different message with alternative correct signature +-- Expect True +(program 1.0.0 + [ + [ + [ + (builtin verifyEcdsaSecp256k1Signature) + (con bytestring #032e433589dce61863199171f4d1e3fa946a5832621fcd29559940a0950f96fb6f) + ] + [(builtin sha2_256) (con bytestring #48656c6c6f210a)] + ] + (con bytestring #fc73d27f308bb0d770db88794e2694cfe5db464764aaa8bcbcafc7c3cadb9e57244f01f2a056cf5345396e8c238972d536e4c67baa7387925d7e028f2192f5d9) + ] +) diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-09/test-vector-09.uplc.budget.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-09/test-vector-09.uplc.budget.expected new file mode 100644 index 00000000000..961b1c22b98 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-09/test-vector-09.uplc.budget.expected @@ -0,0 +1,2 @@ +({cpu: 43490883 +| mem: 1014}) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-09/test-vector-09.uplc.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-09/test-vector-09.uplc.expected new file mode 100644 index 00000000000..3760fc7a698 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-09/test-vector-09.uplc.expected @@ -0,0 +1 @@ +(program 1.0.0 (con bool True)) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-10/test-vector-10.uplc b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-10/test-vector-10.uplc new file mode 100644 index 00000000000..a074baa4c1a --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-10/test-vector-10.uplc @@ -0,0 +1,16 @@ +-- Generated using OpenSSL 3.0.14.4 +-- Signing key 144c76f7eaa087f00a0381d0b7d6ec59eac07d4ac21b58695c1118b10127d821 +-- Same message and signature as test-vector-01, different signing key +-- Expect False +(program 1.0.0 + [ + [ + [ + (builtin verifyEcdsaSecp256k1Signature) + (con bytestring #03173d3b9b964301a4919be323571e64301904209a32631ccc76b42b89d38c6274) + ] + [(builtin sha2_256) (con bytestring #)] + ] + (con bytestring #4941155e2303988a1be97a021fbaf9fe6064d05ea694bc5e89328f297154e5c63a2f3e7b5f509294a4c2e22feb697a16b792fabfebe9d0f38403b1c929836b5a) + ] +) diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-10/test-vector-10.uplc.budget.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-10/test-vector-10.uplc.budget.expected new file mode 100644 index 00000000000..961b1c22b98 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-10/test-vector-10.uplc.budget.expected @@ -0,0 +1,2 @@ +({cpu: 43490883 +| mem: 1014}) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-10/test-vector-10.uplc.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-10/test-vector-10.uplc.expected new file mode 100644 index 00000000000..3ee9f07f31d --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-10/test-vector-10.uplc.expected @@ -0,0 +1 @@ +(program 1.0.0 (con bool False)) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-11/test-vector-11.uplc b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-11/test-vector-11.uplc new file mode 100644 index 00000000000..5ce46f15589 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-11/test-vector-11.uplc @@ -0,0 +1,16 @@ +-- Generated using OpenSSL 3.0.14.4 +-- Signing key 144c76f7eaa087f00a0381d0b7d6ec59eac07d4ac21b58695c1118b10127d821 +-- Same message as test-vector-01, different keypair with correct signature +-- Expect True +(program 1.0.0 + [ + [ + [ + (builtin verifyEcdsaSecp256k1Signature) + (con bytestring #03173d3b9b964301a4919be323571e64301904209a32631ccc76b42b89d38c6274) + ] + [(builtin sha2_256) (con bytestring #)] + ] + (con bytestring #a40e8132923ca042d159f5fba7d2828a79dc212259121a3bfe63445bf3f620fe1b33215f4ca9eb5d41eb8e8304ddc0666236f381f3a88f54cd67740847e91b41) + ] +) diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-11/test-vector-11.uplc.budget.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-11/test-vector-11.uplc.budget.expected new file mode 100644 index 00000000000..961b1c22b98 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-11/test-vector-11.uplc.budget.expected @@ -0,0 +1,2 @@ +({cpu: 43490883 +| mem: 1014}) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-11/test-vector-11.uplc.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-11/test-vector-11.uplc.expected new file mode 100644 index 00000000000..3760fc7a698 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-11/test-vector-11.uplc.expected @@ -0,0 +1 @@ +(program 1.0.0 (con bool True)) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-12/test-vector-12.uplc b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-12/test-vector-12.uplc new file mode 100644 index 00000000000..4105b6c4c16 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-12/test-vector-12.uplc @@ -0,0 +1,16 @@ +-- Generated using OpenSSL 3.0.14.4 +-- Signing key a1adc24fc72eeb3ca032f68134a21c83dbebed4d7088a3794dbe65b4570604fd +-- Same keypair as test-vector-01, large message with correct signature +-- Expect True +(program 1.0.0 + [ + [ + [ + (builtin verifyEcdsaSecp256k1Signature) + (con bytestring #032e433589dce61863199171f4d1e3fa946a5832621fcd29559940a0950f96fb6f) + ] + [(builtin sha2_256) (con bytestring #47616e6761207761732073756e6b656e2c20616e6420746865206c696d70206c65617665730a57616974656420666f72207261696e2c207768696c652074686520626c61636b20636c6f7564730a4761746865726564206661722064697374616e742c206f7665722048696d6176616e742e0a546865206a756e676c652063726f75636865642c2068756d70656420696e2073696c656e63652e0a5468656e2073706f6b6520746865207468756e6465720a44410a44617474613a2077686174206861766520776520676976656e3f0a4d7920667269656e642c20626c6f6f64207368616b696e67206d792068656172740a54686520617766756c20646172696e67206f662061206d6f6d656e74e28099732073757272656e6465720a576869636820616e20616765206f662070727564656e63652063616e206e6576657220726574726163740a427920746869732c20616e642074686973206f6e6c792c207765206861766520657869737465640a5768696368206973206e6f7420746f20626520666f756e6420696e206f7572206f6269747561726965730a4f7220696e206d656d6f7269657320647261706564206279207468652062656e65666963656e74207370696465720a4f7220756e646572207365616c732062726f6b656e20627920746865206c65616e20736f6c696369746f720a496e206f757220656d70747920726f6f6d730a44410a44617961646876616d3a2049206861766520686561726420746865206b65790a5475726e20696e2074686520646f6f72206f6e636520616e64207475726e206f6e6365206f6e6c790a5765207468696e6b206f6620746865206b65792c206561636820696e2068697320707269736f6e0a5468696e6b696e67206f6620746865206b65792c206561636820636f6e6669726d73206120707269736f6e0a4f6e6c79206174206e6967687466616c6c2c2061657468657269616c2072756d6f7572730a52657669766520666f722061206d6f6d656e7420612062726f6b656e20436f72696f6c616e75730a44410a44616d796174613a2054686520626f617420726573706f6e6465640a4761696c792c20746f207468652068616e64206578706572742077697468207361696c20616e64206f61720a54686520736561207761732063616c6d2c20796f757220686561727420776f756c64206861766520726573706f6e6465640a4761696c792c207768656e20696e76697465642c2062656174696e67206f62656469656e740a546f20636f6e74726f6c6c696e672068616e64730a0a20202020202020202020202020202020202020202020202049207361742075706f6e207468652073686f72650a46697368696e672c207769746820746865206172696420706c61696e20626568696e64206d650a5368616c6c2049206174206c6561737420736574206d79206c616e647320696e206f726465723f0a4c6f6e646f6e204272696467652069732066616c6c696e6720646f776e2066616c6c696e6720646f776e2066616c6c696e6720646f776e0a506f692073e280996173636f7365206e656c20666f636f2063686520676c6920616666696e610a5175616e646f206669616d20636575206368656c69646f6e20e28094204f207377616c6c6f77207377616c6c6f770a4c65205072696e63652064e28099417175697461696e6520c3a0206c6120746f75722061626f6c69650a546865736520667261676d656e7473204920686176652073686f72656420616761696e7374206d79207275696e730a576879207468656e20496c652066697420796f752e20486965726f6e796d6fe2809973206d616420616761696e652e0a44617474612e2044617961646876616d2e2044616d796174612e0a2020202020202020202020202020202020202020202020202020205368616e746968202020207368616e746968202020207368616e7469680a)] + ] + (con bytestring #db1f0c781e2d69660525c6f502d38c83c2c62c7004e26d8b860dc9a81cadb3b72f2e2fef4d34b9c869754834e6c785962b3fd0cdd222f47b1a1f2f3388f26c90) + ] +) diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-12/test-vector-12.uplc.budget.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-12/test-vector-12.uplc.budget.expected new file mode 100644 index 00000000000..f090e38eb95 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-12/test-vector-12.uplc.budget.expected @@ -0,0 +1,2 @@ +({cpu: 47511547 +| mem: 1014}) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-12/test-vector-12.uplc.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-12/test-vector-12.uplc.expected new file mode 100644 index 00000000000..3760fc7a698 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-12/test-vector-12.uplc.expected @@ -0,0 +1 @@ +(program 1.0.0 (con bool True)) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-13/test-vector-13.uplc b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-13/test-vector-13.uplc new file mode 100644 index 00000000000..e9595ae92e4 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-13/test-vector-13.uplc @@ -0,0 +1,16 @@ +-- Generated using OpenSSL 3.0.14.4 +-- Signing key a1adc24fc72eeb3ca032f68134a21c83dbebed4d7088a3794dbe65b4570604fd +-- Random message, same signature as test-vector-01 +-- Expect False +(program 1.0.0 + [ + [ + [ + (builtin verifyEcdsaSecp256k1Signature) + (con bytestring #032e433589dce61863199171f4d1e3fa946a5832621fcd29559940a0950f96fb6f) + ] + (con bytestring #377a7d7e7f49244ab617b429ec3b6b764326868236abcfed239427834782abdb) + ] + (con bytestring #4941155e2303988a1be97a021fbaf9fe6064d05ea694bc5e89328f297154e5c63a2f3e7b5f509294a4c2e22feb697a16b792fabfebe9d0f38403b1c929836b5a) + ] +) diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-13/test-vector-13.uplc.budget.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-13/test-vector-13.uplc.budget.expected new file mode 100644 index 00000000000..faa90f4bea4 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-13/test-vector-13.uplc.budget.expected @@ -0,0 +1,2 @@ +({cpu: 43165643 +| mem: 810}) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-13/test-vector-13.uplc.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-13/test-vector-13.uplc.expected new file mode 100644 index 00000000000..3ee9f07f31d --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-13/test-vector-13.uplc.expected @@ -0,0 +1 @@ +(program 1.0.0 (con bool False)) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-14/test-vector-14.uplc b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-14/test-vector-14.uplc new file mode 100644 index 00000000000..e7548fc70a4 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-14/test-vector-14.uplc @@ -0,0 +1,16 @@ +-- Generated using OpenSSL 3.0.14.4 +-- Signing key a1adc24fc72eeb3ca032f68134a21c83dbebed4d7088a3794dbe65b4570604fd +-- Same as test-vector-01, one bit changed in signature +-- Expect False +(program 1.0.0 + [ + [ + [ + (builtin verifyEcdsaSecp256k1Signature) + (con bytestring #032e433589dce61863199171f4d1e3fa946a5832621fcd29559940a0950f96fb6f) + ] + [(builtin sha2_256) (con bytestring #)] + ] + (con bytestring #4941155e2303988a1be97a021fbaf9fe6064d05ea694bc5e89328f297154e5c63a2f3e7b5f509294a2c2e22feb697a16b792fabfebe9d0f38403b1c929836b5a) + ] +) diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-14/test-vector-14.uplc.budget.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-14/test-vector-14.uplc.budget.expected new file mode 100644 index 00000000000..961b1c22b98 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-14/test-vector-14.uplc.budget.expected @@ -0,0 +1,2 @@ +({cpu: 43490883 +| mem: 1014}) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-14/test-vector-14.uplc.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-14/test-vector-14.uplc.expected new file mode 100644 index 00000000000..3ee9f07f31d --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-14/test-vector-14.uplc.expected @@ -0,0 +1 @@ +(program 1.0.0 (con bool False)) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-15/test-vector-15.uplc b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-15/test-vector-15.uplc new file mode 100644 index 00000000000..4cf2f86c879 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-15/test-vector-15.uplc @@ -0,0 +1,16 @@ +-- Generated using OpenSSL 3.0.14.4 +-- Signing key a1adc24fc72eeb3ca032f68134a21c83dbebed4d7088a3794dbe65b4570604fd +-- Same as test-vector-01, one bit changed in verification key +-- Expect False +(program 1.0.0 + [ + [ + [ + (builtin verifyEcdsaSecp256k1Signature) + (con bytestring #032e433589dce61863199171f4d1e3fa946a5832621ecd29559940a0950f96fb6f) + ] + [(builtin sha2_256) (con bytestring #)] + ] + (con bytestring #4941155e2303988a1be97a021fbaf9fe6064d05ea694bc5e89328f297154e5c63a2f3e7b5f509294a4c2e22feb697a16b792fabfebe9d0f38403b1c929836b5a) + ] +) diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-15/test-vector-15.uplc.budget.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-15/test-vector-15.uplc.budget.expected new file mode 100644 index 00000000000..961b1c22b98 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-15/test-vector-15.uplc.budget.expected @@ -0,0 +1,2 @@ +({cpu: 43490883 +| mem: 1014}) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-15/test-vector-15.uplc.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-15/test-vector-15.uplc.expected new file mode 100644 index 00000000000..3ee9f07f31d --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-15/test-vector-15.uplc.expected @@ -0,0 +1 @@ +(program 1.0.0 (con bool False)) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-16/test-vector-16.uplc b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-16/test-vector-16.uplc new file mode 100644 index 00000000000..980d21b0d13 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-16/test-vector-16.uplc @@ -0,0 +1,16 @@ +-- Generated using OpenSSL 3.0.14.4 +-- Signing key a1adc24fc72eeb3ca032f68134a21c83dbebed4d7088a3794dbe65b4570604fd +-- Same as test-vector-01, but verification key adjusted to be off the curve. +-- Expect error +(program 1.0.0 + [ + [ + [ + (builtin verifyEcdsaSecp256k1Signature) + (con bytestring #032e433589dce61863199171f4d1e3fa946a5832621fcd29559940a0950f96fb61) + ] + [(builtin sha2_256) (con bytestring #)] + ] + (con bytestring #4941155e2303988a1be97a021fbaf9fe6064d05ea694bc5e89328f297154e5c63a2f3e7b5f509294a4c2e22feb697a16b792fabfebe9d0f38403b1c929836b5a) + ] +) diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-16/test-vector-16.uplc.budget.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-16/test-vector-16.uplc.budget.expected new file mode 100644 index 00000000000..ccc477ffed6 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-16/test-vector-16.uplc.budget.expected @@ -0,0 +1 @@ +evaluation failure \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-16/test-vector-16.uplc.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-16/test-vector-16.uplc.expected new file mode 100644 index 00000000000..ccc477ffed6 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-16/test-vector-16.uplc.expected @@ -0,0 +1 @@ +evaluation failure \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-17/test-vector-17.uplc b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-17/test-vector-17.uplc new file mode 100644 index 00000000000..e0f8186af3d --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-17/test-vector-17.uplc @@ -0,0 +1,17 @@ +-- Generated using OpenSSL 3.0.14.4 +-- Signing key a1adc24fc72eeb3ca032f68134a21c83dbebed4d7088a3794dbe65b4570604fd +-- Same as test-vector-01, but with the r component of the signature adjusted to +-- be out of range (equal to the group order): one less -> False, not error +-- Expect error +(program 1.0.0 + [ + [ + [ + (builtin verifyEcdsaSecp256k1Signature) + (con bytestring #032e433589dce61863199171f4d1e3fa946a5832621fcd29559940a0950f96fb6f) + ] + [(builtin sha2_256) (con bytestring #)] + ] + (con bytestring #fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd03641413a2f3e7b5f509294a4c2e22feb697a16b792fabfebe9d0f38403b1c929836b5a) + ] +) diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-17/test-vector-17.uplc.budget.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-17/test-vector-17.uplc.budget.expected new file mode 100644 index 00000000000..ccc477ffed6 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-17/test-vector-17.uplc.budget.expected @@ -0,0 +1 @@ +evaluation failure \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-17/test-vector-17.uplc.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-17/test-vector-17.uplc.expected new file mode 100644 index 00000000000..ccc477ffed6 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-17/test-vector-17.uplc.expected @@ -0,0 +1 @@ +evaluation failure \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-18/test-vector-18.uplc b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-18/test-vector-18.uplc new file mode 100644 index 00000000000..55d9c022e53 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-18/test-vector-18.uplc @@ -0,0 +1,17 @@ +-- Generated using OpenSSL 3.0.14.4 +-- Signing key a1adc24fc72eeb3ca032f68134a21c83dbebed4d7088a3794dbe65b4570604fd +-- Same as test-vector-01, but with the s component of the signature adjusted to +-- be out of range (equal to the group order): one less -> False, not error +-- Expect error +(program 1.0.0 + [ + [ + [ + (builtin verifyEcdsaSecp256k1Signature) + (con bytestring #032e433589dce61863199171f4d1e3fa946a5832621fcd29559940a0950f96fb6f) + ] + [(builtin sha2_256) (con bytestring #)] + ] + (con bytestring #4941155e2303988a1be97a021fbaf9fe6064d05ea694bc5e89328f297154e5c6fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141) + ] +) diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-18/test-vector-18.uplc.budget.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-18/test-vector-18.uplc.budget.expected new file mode 100644 index 00000000000..ccc477ffed6 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-18/test-vector-18.uplc.budget.expected @@ -0,0 +1 @@ +evaluation failure \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-18/test-vector-18.uplc.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-18/test-vector-18.uplc.expected new file mode 100644 index 00000000000..ccc477ffed6 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifyEcdsaSecp256k1Signature/test-vector-18/test-vector-18.uplc.expected @@ -0,0 +1 @@ +evaluation failure \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-00/test-vector-00.uplc b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-00/test-vector-00.uplc new file mode 100644 index 00000000000..c97681d00ca --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-00/test-vector-00.uplc @@ -0,0 +1,13 @@ +-- Test vector 0 from https://raw.githubusercontent.com/bitcoin/bips/master/bip-0340/test-vectors.csv +-- Expect True +(program 1.0.0 + [ + [ + [(builtin verifySchnorrSecp256k1Signature) + (con bytestring #f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9) + ] + (con bytestring #0000000000000000000000000000000000000000000000000000000000000000) + ] + (con bytestring #e907831f80848d1069a5371b402410364bdf1c5f8307b0084c55f1ce2dca821525f66a4a85ea8b71e482a74f382d2ce5ebeee8fdb2172f477df4900d310536c0) + ] +) diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-00/test-vector-00.uplc.budget.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-00/test-vector-00.uplc.budget.expected new file mode 100644 index 00000000000..46e70e728d4 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-00/test-vector-00.uplc.budget.expected @@ -0,0 +1,2 @@ +({cpu: 43791615 +| mem: 810}) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-00/test-vector-00.uplc.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-00/test-vector-00.uplc.expected new file mode 100644 index 00000000000..3760fc7a698 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-00/test-vector-00.uplc.expected @@ -0,0 +1 @@ +(program 1.0.0 (con bool True)) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-01/test-vector-01.uplc b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-01/test-vector-01.uplc new file mode 100644 index 00000000000..ef702465ac4 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-01/test-vector-01.uplc @@ -0,0 +1,13 @@ +-- Test vector 1 from https://raw.githubusercontent.com/bitcoin/bips/master/bip-0340/test-vectors.csv +-- Expect True +(program 1.0.0 + [ + [ + [(builtin verifySchnorrSecp256k1Signature) + (con bytestring #dff1d77f2a671c5f36183726db2341be58feae1da2deced843240f7b502ba659) + ] + (con bytestring #243f6a8885a308d313198a2e03707344a4093822299f31d0082efa98ec4e6c89) + ] + (con bytestring #6896bd60eeae296db48a229ff71dfe071bde413e6d43f917dc8dcf8c78de33418906d11ac976abccb20b091292bff4ea897efcb639ea871cfa95f6de339e4b0a) + ] +) diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-01/test-vector-01.uplc.budget.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-01/test-vector-01.uplc.budget.expected new file mode 100644 index 00000000000..46e70e728d4 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-01/test-vector-01.uplc.budget.expected @@ -0,0 +1,2 @@ +({cpu: 43791615 +| mem: 810}) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-01/test-vector-01.uplc.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-01/test-vector-01.uplc.expected new file mode 100644 index 00000000000..3760fc7a698 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-01/test-vector-01.uplc.expected @@ -0,0 +1 @@ +(program 1.0.0 (con bool True)) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-02/test-vector-02.uplc b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-02/test-vector-02.uplc new file mode 100644 index 00000000000..93bf9e19fd9 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-02/test-vector-02.uplc @@ -0,0 +1,13 @@ +-- Test vector 2 from https://raw.githubusercontent.com/bitcoin/bips/master/bip-0340/test-vectors.csv +-- Expect True +(program 1.0.0 + [ + [ + [(builtin verifySchnorrSecp256k1Signature) + (con bytestring #dd308afec5777e13121fa72b9cc1b7cc0139715309b086c960e18fd969774eb8) + ] + (con bytestring #7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c) + ] + (con bytestring #5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7) + ] +) diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-02/test-vector-02.uplc.budget.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-02/test-vector-02.uplc.budget.expected new file mode 100644 index 00000000000..46e70e728d4 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-02/test-vector-02.uplc.budget.expected @@ -0,0 +1,2 @@ +({cpu: 43791615 +| mem: 810}) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-02/test-vector-02.uplc.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-02/test-vector-02.uplc.expected new file mode 100644 index 00000000000..3760fc7a698 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-02/test-vector-02.uplc.expected @@ -0,0 +1 @@ +(program 1.0.0 (con bool True)) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-03/test-vector-03.uplc b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-03/test-vector-03.uplc new file mode 100644 index 00000000000..1a49bacac3c --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-03/test-vector-03.uplc @@ -0,0 +1,13 @@ +-- Test vector 3 from https://raw.githubusercontent.com/bitcoin/bips/master/bip-0340/test-vectors.csv +-- Expect True (test fails if msg is reduced modulo p or n) +(program 1.0.0 + [ + [ + [(builtin verifySchnorrSecp256k1Signature) + (con bytestring #25d1dff95105f5253c4022f628a996ad3a0d95fbf21d468a1b33f8c160d8f517) + ] + (con bytestring #ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) + ] + (con bytestring #7eb0509757e246f19449885651611cb965ecc1a187dd51b64fda1edc9637d5ec97582b9cb13db3933705b32ba982af5af25fd78881ebb32771fc5922efc66ea3) + ] +) diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-03/test-vector-03.uplc.budget.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-03/test-vector-03.uplc.budget.expected new file mode 100644 index 00000000000..46e70e728d4 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-03/test-vector-03.uplc.budget.expected @@ -0,0 +1,2 @@ +({cpu: 43791615 +| mem: 810}) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-03/test-vector-03.uplc.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-03/test-vector-03.uplc.expected new file mode 100644 index 00000000000..3760fc7a698 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-03/test-vector-03.uplc.expected @@ -0,0 +1 @@ +(program 1.0.0 (con bool True)) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-04/test-vector-04.uplc b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-04/test-vector-04.uplc new file mode 100644 index 00000000000..ca134be6a17 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-04/test-vector-04.uplc @@ -0,0 +1,13 @@ +-- Test vector 4 from https://raw.githubusercontent.com/bitcoin/bips/master/bip-0340/test-vectors.csv +-- Expect True +(program 1.0.0 + [ + [ + [(builtin verifySchnorrSecp256k1Signature) + (con bytestring #d69c3509bb99e412e68b0fe8544e72837dfa30746d8be2aa65975f29d22dc7b9) + ] + (con bytestring #4df3c3f68fcc83b27e9d42c90431a72499f17875c81a599b566c9889b9696703) + ] + (con bytestring #00000000000000000000003b78ce563f89a0ed9414f5aa28ad0d96d6795f9c6376afb1548af603b3eb45c9f8207dee1060cb71c04e80f593060b07d28308d7f4) + ] +) diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-04/test-vector-04.uplc.budget.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-04/test-vector-04.uplc.budget.expected new file mode 100644 index 00000000000..46e70e728d4 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-04/test-vector-04.uplc.budget.expected @@ -0,0 +1,2 @@ +({cpu: 43791615 +| mem: 810}) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-04/test-vector-04.uplc.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-04/test-vector-04.uplc.expected new file mode 100644 index 00000000000..3760fc7a698 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-04/test-vector-04.uplc.expected @@ -0,0 +1 @@ +(program 1.0.0 (con bool True)) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-05/test-vector-05.uplc b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-05/test-vector-05.uplc new file mode 100644 index 00000000000..5998243d11e --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-05/test-vector-05.uplc @@ -0,0 +1,13 @@ +-- Test vector 5 from https://raw.githubusercontent.com/bitcoin/bips/master/bip-0340/test-vectors.csv +-- Expect failure (public key not on the curve) +(program 1.0.0 + [ + [ + [(builtin verifySchnorrSecp256k1Signature) + (con bytestring #eefdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34) + ] + (con bytestring #243f6a8885a308d313198a2e03707344a4093822299f31d0082efa98ec4e6c89) + ] + (con bytestring #6cff5c3ba86c69ea4b7376f31a9bcb4f74c1976089b2d9963da2e5543e17776969e89b4c5564d00349106b8497785dd7d1d713a8ae82b32fa79d5f7fc407d39b) + ] +) diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-05/test-vector-05.uplc.budget.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-05/test-vector-05.uplc.budget.expected new file mode 100644 index 00000000000..ccc477ffed6 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-05/test-vector-05.uplc.budget.expected @@ -0,0 +1 @@ +evaluation failure \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-05/test-vector-05.uplc.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-05/test-vector-05.uplc.expected new file mode 100644 index 00000000000..ccc477ffed6 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-05/test-vector-05.uplc.expected @@ -0,0 +1 @@ +evaluation failure \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-06/test-vector-06.uplc b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-06/test-vector-06.uplc new file mode 100644 index 00000000000..7f609cfb566 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-06/test-vector-06.uplc @@ -0,0 +1,13 @@ +-- Test vector 6 from https://raw.githubusercontent.com/bitcoin/bips/master/bip-0340/test-vectors.csv +-- Expect False (has_even_y(R) is false) +(program 1.0.0 + [ + [ + [(builtin verifySchnorrSecp256k1Signature) + (con bytestring #dff1d77f2a671c5f36183726db2341be58feae1da2deced843240f7b502ba659) + ] + (con bytestring #243f6a8885a308d313198a2e03707344a4093822299f31d0082efa98ec4e6c89) + ] + (con bytestring #fff97bd5755eeea420453a14355235d382f6472f8568a18b2f057a14602975563cc27944640ac607cd107ae10923d9ef7a73c643e166be5ebeafa34b1ac553e2) + ] +) diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-06/test-vector-06.uplc.budget.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-06/test-vector-06.uplc.budget.expected new file mode 100644 index 00000000000..46e70e728d4 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-06/test-vector-06.uplc.budget.expected @@ -0,0 +1,2 @@ +({cpu: 43791615 +| mem: 810}) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-06/test-vector-06.uplc.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-06/test-vector-06.uplc.expected new file mode 100644 index 00000000000..3ee9f07f31d --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-06/test-vector-06.uplc.expected @@ -0,0 +1 @@ +(program 1.0.0 (con bool False)) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-07/test-vector-07.uplc b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-07/test-vector-07.uplc new file mode 100644 index 00000000000..52523a5a133 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-07/test-vector-07.uplc @@ -0,0 +1,13 @@ +-- Test vector 7 from https://raw.githubusercontent.com/bitcoin/bips/master/bip-0340/test-vectors.csv +-- Expect False (negated message) +(program 1.0.0 + [ + [ + [(builtin verifySchnorrSecp256k1Signature) + (con bytestring #dff1d77f2a671c5f36183726db2341be58feae1da2deced843240f7b502ba659) + ] + (con bytestring #243f6a8885a308d313198a2e03707344a4093822299f31d0082efa98ec4e6c89) + ] + (con bytestring #1fa62e331edbc21c394792d2ab1100a7b432b013df3f6ff4f99fcb33e0e1515f28890b3edb6e7189b630448b515ce4f8622a954cfe545735aaea5134fccdb2bd) + ] +) diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-07/test-vector-07.uplc.budget.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-07/test-vector-07.uplc.budget.expected new file mode 100644 index 00000000000..46e70e728d4 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-07/test-vector-07.uplc.budget.expected @@ -0,0 +1,2 @@ +({cpu: 43791615 +| mem: 810}) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-07/test-vector-07.uplc.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-07/test-vector-07.uplc.expected new file mode 100644 index 00000000000..3ee9f07f31d --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-07/test-vector-07.uplc.expected @@ -0,0 +1 @@ +(program 1.0.0 (con bool False)) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-08/test-vector-08.uplc b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-08/test-vector-08.uplc new file mode 100644 index 00000000000..27fe594ab66 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-08/test-vector-08.uplc @@ -0,0 +1,13 @@ +-- Test vector 8 from https://raw.githubusercontent.com/bitcoin/bips/master/bip-0340/test-vectors.csv +-- Expect False (negated s value) +(program 1.0.0 + [ + [ + [(builtin verifySchnorrSecp256k1Signature) + (con bytestring #dff1d77f2a671c5f36183726db2341be58feae1da2deced843240f7b502ba659) + ] + (con bytestring #243f6a8885a308d313198a2e03707344a4093822299f31d0082efa98ec4e6c89) + ] + (con bytestring #6cff5c3ba86c69ea4b7376f31a9bcb4f74c1976089b2d9963da2e5543e177769961764b3aa9b2ffcb6ef947b6887a226e8d7c93e00c5ed0c1834ff0d0c2e6da6) + ] +) diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-08/test-vector-08.uplc.budget.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-08/test-vector-08.uplc.budget.expected new file mode 100644 index 00000000000..46e70e728d4 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-08/test-vector-08.uplc.budget.expected @@ -0,0 +1,2 @@ +({cpu: 43791615 +| mem: 810}) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-08/test-vector-08.uplc.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-08/test-vector-08.uplc.expected new file mode 100644 index 00000000000..3ee9f07f31d --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-08/test-vector-08.uplc.expected @@ -0,0 +1 @@ +(program 1.0.0 (con bool False)) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-09/test-vector-09.uplc b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-09/test-vector-09.uplc new file mode 100644 index 00000000000..fd0d06136d0 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-09/test-vector-09.uplc @@ -0,0 +1,14 @@ +-- Test vector 9 from https://raw.githubusercontent.com/bitcoin/bips/master/bip-0340/test-vectors.csv +-- Expect False +-- (sG - eP is infinite. Test fails in single verification if has_even_y(inf) is defined as true and x(inf) as 0) +(program 1.0.0 + [ + [ + [(builtin verifySchnorrSecp256k1Signature) + (con bytestring #dff1d77f2a671c5f36183726db2341be58feae1da2deced843240f7b502ba659) + ] + (con bytestring #243f6a8885a308d313198a2e03707344a4093822299f31d0082efa98ec4e6c89) + ] + (con bytestring #0000000000000000000000000000000000000000000000000000000000000000123dda8328af9c23a94c1feecfd123ba4fb73476f0d594dcb65c6425bd186051) + ] +) diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-09/test-vector-09.uplc.budget.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-09/test-vector-09.uplc.budget.expected new file mode 100644 index 00000000000..46e70e728d4 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-09/test-vector-09.uplc.budget.expected @@ -0,0 +1,2 @@ +({cpu: 43791615 +| mem: 810}) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-09/test-vector-09.uplc.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-09/test-vector-09.uplc.expected new file mode 100644 index 00000000000..3ee9f07f31d --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-09/test-vector-09.uplc.expected @@ -0,0 +1 @@ +(program 1.0.0 (con bool False)) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-10/test-vector-10.uplc b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-10/test-vector-10.uplc new file mode 100644 index 00000000000..76107a89bc8 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-10/test-vector-10.uplc @@ -0,0 +1,14 @@ +-- Test vector 10 from https://raw.githubusercontent.com/bitcoin/bips/master/bip-0340/test-vectors.csv +-- Expect False +-- (sG - eP is infinite. Test fails in single verification if has_even_y(inf) is defined as true and x(inf) as 1) +(program 1.0.0 + [ + [ + [(builtin verifySchnorrSecp256k1Signature) + (con bytestring #dff1d77f2a671c5f36183726db2341be58feae1da2deced843240f7b502ba659) + ] + (con bytestring #243f6a8885a308d313198a2e03707344a4093822299f31d0082efa98ec4e6c89) + ] + (con bytestring #00000000000000000000000000000000000000000000000000000000000000017615fbaf5ae28864013c099742deadb4dba87f11ac6754f93780d5a1837cf197) + ] +) diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-10/test-vector-10.uplc.budget.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-10/test-vector-10.uplc.budget.expected new file mode 100644 index 00000000000..46e70e728d4 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-10/test-vector-10.uplc.budget.expected @@ -0,0 +1,2 @@ +({cpu: 43791615 +| mem: 810}) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-10/test-vector-10.uplc.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-10/test-vector-10.uplc.expected new file mode 100644 index 00000000000..3ee9f07f31d --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-10/test-vector-10.uplc.expected @@ -0,0 +1 @@ +(program 1.0.0 (con bool False)) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-11/test-vector-11.uplc b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-11/test-vector-11.uplc new file mode 100644 index 00000000000..d4799ffc835 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-11/test-vector-11.uplc @@ -0,0 +1,13 @@ +-- Test vector 11 from https://raw.githubusercontent.com/bitcoin/bips/master/bip-0340/test-vectors.csv +-- Expect False (sig[0:32] is not an X coordinate on the curve) +(program 1.0.0 + [ + [ + [(builtin verifySchnorrSecp256k1Signature) + (con bytestring #dff1d77f2a671c5f36183726db2341be58feae1da2deced843240f7b502ba659) + ] + (con bytestring #243f6a8885a308d313198a2e03707344a4093822299f31d0082efa98ec4e6c89) + ] + (con bytestring #4a298dacae57395a15d0795ddbfd1dcb564da82b0f269bc70a74f8220429ba1d69e89b4c5564d00349106b8497785dd7d1d713a8ae82b32fa79d5f7fc407d39b) + ] +) diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-11/test-vector-11.uplc.budget.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-11/test-vector-11.uplc.budget.expected new file mode 100644 index 00000000000..46e70e728d4 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-11/test-vector-11.uplc.budget.expected @@ -0,0 +1,2 @@ +({cpu: 43791615 +| mem: 810}) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-11/test-vector-11.uplc.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-11/test-vector-11.uplc.expected new file mode 100644 index 00000000000..3ee9f07f31d --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-11/test-vector-11.uplc.expected @@ -0,0 +1 @@ +(program 1.0.0 (con bool False)) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-12/test-vector-12.uplc b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-12/test-vector-12.uplc new file mode 100644 index 00000000000..8d949e4590a --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-12/test-vector-12.uplc @@ -0,0 +1,13 @@ +-- Test vector 12 from https://raw.githubusercontent.com/bitcoin/bips/master/bip-0340/test-vectors.csv +-- Expect False (sig[0:32] is equal to field size) +(program 1.0.0 + [ + [ + [(builtin verifySchnorrSecp256k1Signature) + (con bytestring #dff1d77f2a671c5f36183726db2341be58feae1da2deced843240f7b502ba659) + ] + (con bytestring #243f6a8885a308d313198a2e03707344a4093822299f31d0082efa98ec4e6c89) + ] + (con bytestring #fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f69e89b4c5564d00349106b8497785dd7d1d713a8ae82b32fa79d5f7fc407d39b) + ] +) diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-12/test-vector-12.uplc.budget.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-12/test-vector-12.uplc.budget.expected new file mode 100644 index 00000000000..46e70e728d4 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-12/test-vector-12.uplc.budget.expected @@ -0,0 +1,2 @@ +({cpu: 43791615 +| mem: 810}) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-12/test-vector-12.uplc.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-12/test-vector-12.uplc.expected new file mode 100644 index 00000000000..3ee9f07f31d --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-12/test-vector-12.uplc.expected @@ -0,0 +1 @@ +(program 1.0.0 (con bool False)) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-13/test-vector-13.uplc b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-13/test-vector-13.uplc new file mode 100644 index 00000000000..33c32fe69c7 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-13/test-vector-13.uplc @@ -0,0 +1,13 @@ +-- Test vector 13 from https://raw.githubusercontent.com/bitcoin/bips/master/bip-0340/test-vectors.csv +-- Expect False (sig[32:64] is equal to curve order) +(program 1.0.0 + [ + [ + [(builtin verifySchnorrSecp256k1Signature) + (con bytestring #dff1d77f2a671c5f36183726db2341be58feae1da2deced843240f7b502ba659) + ] + (con bytestring #243f6a8885a308d313198a2e03707344a4093822299f31d0082efa98ec4e6c89) + ] + (con bytestring #6cff5c3ba86c69ea4b7376f31a9bcb4f74c1976089b2d9963da2e5543e177769fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141) + ] +) diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-13/test-vector-13.uplc.budget.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-13/test-vector-13.uplc.budget.expected new file mode 100644 index 00000000000..46e70e728d4 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-13/test-vector-13.uplc.budget.expected @@ -0,0 +1,2 @@ +({cpu: 43791615 +| mem: 810}) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-13/test-vector-13.uplc.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-13/test-vector-13.uplc.expected new file mode 100644 index 00000000000..3ee9f07f31d --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-13/test-vector-13.uplc.expected @@ -0,0 +1 @@ +(program 1.0.0 (con bool False)) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-14/test-vector-14.uplc b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-14/test-vector-14.uplc new file mode 100644 index 00000000000..c871a36d57f --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-14/test-vector-14.uplc @@ -0,0 +1,13 @@ +-- Test vector 14 from https://raw.githubusercontent.com/bitcoin/bips/master/bip-0340/test-vectors.csv +-- Expect failure (public key is not a valid X coordinate because it exceeds the field size) +(program 1.0.0 + [ + [ + [(builtin verifySchnorrSecp256k1Signature) + (con bytestring #fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc30) + ] + (con bytestring #243f6a8885a308d313198a2e03707344a4093822299f31d0082efa98ec4e6c89) + ] + (con bytestring #6cff5c3ba86c69ea4b7376f31a9bcb4f74c1976089b2d9963da2e5543e17776969e89b4c5564d00349106b8497785dd7d1d713a8ae82b32fa79d5f7fc407d39b) + ] +) diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-14/test-vector-14.uplc.budget.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-14/test-vector-14.uplc.budget.expected new file mode 100644 index 00000000000..ccc477ffed6 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-14/test-vector-14.uplc.budget.expected @@ -0,0 +1 @@ +evaluation failure \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-14/test-vector-14.uplc.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-14/test-vector-14.uplc.expected new file mode 100644 index 00000000000..ccc477ffed6 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-14/test-vector-14.uplc.expected @@ -0,0 +1 @@ +evaluation failure \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-15/test-vector-15.uplc b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-15/test-vector-15.uplc new file mode 100644 index 00000000000..aec501edeb7 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-15/test-vector-15.uplc @@ -0,0 +1,13 @@ +-- Test vector 15 from https://raw.githubusercontent.com/bitcoin/bips/master/bip-0340/test-vectors.csv +-- Expect True (message of size 0) +(program 1.0.0 + [ + [ + [(builtin verifySchnorrSecp256k1Signature) + (con bytestring #778caa53b4393ac467774d09497a87224bf9fab6f6e68b23086497324d6fd117) + ] + (con bytestring #) + ] + (con bytestring #71535db165ecd9fbbc046e5ffaea61186bb6ad436732fccc25291a55895464cf6069ce26bf03466228f19a3a62db8a649f2d560fac652827d1af0574e427ab63) + ] +) diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-15/test-vector-15.uplc.budget.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-15/test-vector-15.uplc.budget.expected new file mode 100644 index 00000000000..05b3ff6230f --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-15/test-vector-15.uplc.budget.expected @@ -0,0 +1,2 @@ +({cpu: 43712691 +| mem: 810}) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-15/test-vector-15.uplc.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-15/test-vector-15.uplc.expected new file mode 100644 index 00000000000..3760fc7a698 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-15/test-vector-15.uplc.expected @@ -0,0 +1 @@ +(program 1.0.0 (con bool True)) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-16/test-vector-16.uplc b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-16/test-vector-16.uplc new file mode 100644 index 00000000000..300a03b7ebf --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-16/test-vector-16.uplc @@ -0,0 +1,13 @@ +-- Test vector 16 from https://raw.githubusercontent.com/bitcoin/bips/master/bip-0340/test-vectors.csv +-- Expect True (message of size 1 (added 2022-12) +(program 1.0.0 + [ + [ + [(builtin verifySchnorrSecp256k1Signature) + (con bytestring #778caa53b4393ac467774d09497a87224bf9fab6f6e68b23086497324d6fd117) + ] + (con bytestring #11) + ] + (con bytestring #08a20a0afef64124649232e0693c583ab1b9934ae63b4c3511f3ae1134c6a303ea3173bfea6683bd101fa5aa5dbc1996fe7cacfc5a577d33ec14564cec2bacbf) + ] +) diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-16/test-vector-16.uplc.budget.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-16/test-vector-16.uplc.budget.expected new file mode 100644 index 00000000000..05b3ff6230f --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-16/test-vector-16.uplc.budget.expected @@ -0,0 +1,2 @@ +({cpu: 43712691 +| mem: 810}) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-16/test-vector-16.uplc.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-16/test-vector-16.uplc.expected new file mode 100644 index 00000000000..3760fc7a698 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-16/test-vector-16.uplc.expected @@ -0,0 +1 @@ +(program 1.0.0 (con bool True)) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-17/test-vector-17.uplc b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-17/test-vector-17.uplc new file mode 100644 index 00000000000..e20832d5a49 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-17/test-vector-17.uplc @@ -0,0 +1,13 @@ +-- Test vector 17 from https://raw.githubusercontent.com/bitcoin/bips/master/bip-0340/test-vectors.csv +-- Expect True (message of size 17) +(program 1.0.0 + [ + [ + [(builtin verifySchnorrSecp256k1Signature) + (con bytestring #778caa53b4393ac467774d09497a87224bf9fab6f6e68b23086497324d6fd117) + ] + (con bytestring #0102030405060708090a0b0c0d0e0f1011) + ] + (con bytestring #5130f39a4059b43bc7cac09a19ece52b5d8699d1a71e3c52da9afdb6b50ac370c4a482b77bf960f8681540e25b6771ece1e5a37fd80e5a51897c5566a97ea5a5) + ] +) diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-17/test-vector-17.uplc.budget.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-17/test-vector-17.uplc.budget.expected new file mode 100644 index 00000000000..4267a5f9da7 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-17/test-vector-17.uplc.budget.expected @@ -0,0 +1,2 @@ +({cpu: 43765307 +| mem: 810}) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-17/test-vector-17.uplc.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-17/test-vector-17.uplc.expected new file mode 100644 index 00000000000..3760fc7a698 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-17/test-vector-17.uplc.expected @@ -0,0 +1 @@ +(program 1.0.0 (con bool True)) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-18/test-vector-18.uplc b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-18/test-vector-18.uplc new file mode 100644 index 00000000000..dc5a193e68c --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-18/test-vector-18.uplc @@ -0,0 +1,13 @@ +-- Test vector 18 from https://raw.githubusercontent.com/bitcoin/bips/master/bip-0340/test-vectors.csv +-- Expect True (message of size 100) +(program 1.0.0 + [ + [ + [(builtin verifySchnorrSecp256k1Signature) + (con bytestring #778caa53b4393ac467774d09497a87224bf9fab6f6e68b23086497324d6fd117) + ] + (con bytestring #99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999) + ] + (con bytestring #403b12b0d8555a344175ea7ec746566303321e5dbfa8be6f091635163eca79a8585ed3e3170807e7c03b720fc54c7b23897fcba0e9d0b4a06894cfd249f22367) + ] +) diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-18/test-vector-18.uplc.budget.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-18/test-vector-18.uplc.budget.expected new file mode 100644 index 00000000000..98b89edd87f --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-18/test-vector-18.uplc.budget.expected @@ -0,0 +1,2 @@ +({cpu: 44028387 +| mem: 810}) \ No newline at end of file diff --git a/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-18/test-vector-18.uplc.expected b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-18/test-vector-18.uplc.expected new file mode 100644 index 00000000000..3760fc7a698 --- /dev/null +++ b/plutus-conformance/test-cases/uplc/evaluation/builtin/semantics/verifySchnorrSecp256k1Signature/test-vector-18/test-vector-18.uplc.expected @@ -0,0 +1 @@ +(program 1.0.0 (con bool True)) \ No newline at end of file diff --git a/plutus-ledger-api/changelog.d/20241031_172446_Yuriy.Lazaryev_mint_value.md b/plutus-ledger-api/changelog.d/20241031_172446_Yuriy.Lazaryev_mint_value.md new file mode 100644 index 00000000000..35343e93df5 --- /dev/null +++ b/plutus-ledger-api/changelog.d/20241031_172446_Yuriy.Lazaryev_mint_value.md @@ -0,0 +1,4 @@ +### Changed + +- 'txInfoMint' function now returns 'MintValue' instead of 'Value' for minted values. This change +addresses problem described in the issue #5781. diff --git a/plutus-ledger-api/exe/analyse-script-events/Main.hs b/plutus-ledger-api/exe/analyse-script-events/Main.hs index 8758413c26b..2e873cd64b6 100644 --- a/plutus-ledger-api/exe/analyse-script-events/Main.hs +++ b/plutus-ledger-api/exe/analyse-script-events/Main.hs @@ -112,7 +112,9 @@ analyseTxInfoV3 i = do putStr "Fee: " print $ V3.txInfoFee i putStr "Mint: " - analyseValue $ V3.txInfoMint i + analyseValue $ V3.mintValueMinted (V3.txInfoMint i) + putStr "Burn: " + analyseValue $ V3.mintValueBurned (V3.txInfoMint i) analyseOutputs (V3.txInfoOutputs i) V3.txOutValue analyseScriptContext :: EventAnalyser diff --git a/plutus-ledger-api/plutus-ledger-api.cabal b/plutus-ledger-api/plutus-ledger-api.cabal index e5cf081b9a8..4f0231b3463 100644 --- a/plutus-ledger-api/plutus-ledger-api.cabal +++ b/plutus-ledger-api/plutus-ledger-api.cabal @@ -89,6 +89,7 @@ library PlutusLedgerApi.V3.Contexts PlutusLedgerApi.V3.Data.Contexts PlutusLedgerApi.V3.EvaluationContext + PlutusLedgerApi.V3.MintValue PlutusLedgerApi.V3.ParamName PlutusLedgerApi.V3.Tx @@ -133,6 +134,7 @@ library plutus-ledger-api-testlib PlutusLedgerApi.Test.V2.EvaluationContext PlutusLedgerApi.Test.V3.Data.EvaluationContext PlutusLedgerApi.Test.V3.EvaluationContext + PlutusLedgerApi.Test.V3.MintValue build-depends: , barbies @@ -169,6 +171,7 @@ test-suite plutus-ledger-api-test Spec.ScriptDecodeError Spec.V1.Data.Value Spec.V1.Value + Spec.V3.MintValue Spec.Versions build-depends: diff --git a/plutus-ledger-api/src/PlutusLedgerApi/V3.hs b/plutus-ledger-api/src/PlutusLedgerApi/V3.hs index 21de2d427a0..6b00a3dff89 100644 --- a/plutus-ledger-api/src/PlutusLedgerApi/V3.hs +++ b/plutus-ledger-api/src/PlutusLedgerApi/V3.hs @@ -85,6 +85,13 @@ module PlutusLedgerApi.V3 ( V2.adaToken, V2.Lovelace (..), + -- *** Mint Value + MintValue.MintValue, + MintValue.emptyMintValue, + MintValue.mintValueToMap, + MintValue.mintValueMinted, + MintValue.mintValueBurned, + -- *** Time V2.POSIXTime (..), V2.POSIXTimeRange, @@ -152,6 +159,7 @@ import PlutusLedgerApi.Common qualified as Common import PlutusLedgerApi.V2 qualified as V2 import PlutusLedgerApi.V3.Contexts qualified as Contexts import PlutusLedgerApi.V3.EvaluationContext qualified as EvaluationContext +import PlutusLedgerApi.V3.MintValue qualified as MintValue import PlutusLedgerApi.V3.ParamName qualified as ParamName import PlutusLedgerApi.V3.Tx qualified as Tx import PlutusTx.Ratio qualified as Ratio diff --git a/plutus-ledger-api/src/PlutusLedgerApi/V3/Contexts.hs b/plutus-ledger-api/src/PlutusLedgerApi/V3/Contexts.hs index 57737538bdb..3c174057186 100644 --- a/plutus-ledger-api/src/PlutusLedgerApi/V3/Contexts.hs +++ b/plutus-ledger-api/src/PlutusLedgerApi/V3/Contexts.hs @@ -58,6 +58,7 @@ import Data.Function ((&)) import Data.Maybe (Maybe (..)) import GHC.Generics (Generic) import PlutusLedgerApi.V2 qualified as V2 +import PlutusLedgerApi.V3.MintValue qualified as V3 import PlutusLedgerApi.V3.Tx qualified as V3 import PlutusTx (makeIsDataSchemaIndexed) import PlutusTx qualified @@ -65,16 +66,15 @@ import PlutusTx.AssocMap (Map, lookup, toList) import PlutusTx.Blueprint (HasBlueprintDefinition, HasBlueprintSchema, HasSchemaDefinition, Schema (SchemaBuiltInData), SchemaInfo (..), emptySchemaInfo) import PlutusTx.Blueprint.Class (HasBlueprintSchema (..)) +import PlutusTx.Blueprint.Definition.Derive (definitionRef) import PlutusTx.Blueprint.Schema (withSchemaInfo) import PlutusTx.Lift (makeLift) import PlutusTx.Prelude qualified as PlutusTx import PlutusTx.Ratio (Rational) +import Prelude qualified as Haskell import Prettyprinter (nest, vsep, (<+>)) import Prettyprinter.Extras (Pretty (pretty), PrettyShow (PrettyShow)) -import PlutusTx.Blueprint.Definition.Derive (definitionRef) -import Prelude qualified as Haskell - newtype ColdCommitteeCredential = ColdCommitteeCredential V2.Credential deriving stock (Generic) deriving anyclass (HasBlueprintDefinition) @@ -480,7 +480,7 @@ data TxInfo = TxInfo , txInfoReferenceInputs :: [TxInInfo] , txInfoOutputs :: [V2.TxOut] , txInfoFee :: V2.Lovelace - , txInfoMint :: V2.Value + , txInfoMint :: V3.MintValue -- ^ The 'Value' minted by this transaction. -- -- /Invariant:/ This field does not contain Ada with zero quantity, unlike diff --git a/plutus-ledger-api/src/PlutusLedgerApi/V3/MintValue.hs b/plutus-ledger-api/src/PlutusLedgerApi/V3/MintValue.hs new file mode 100644 index 00000000000..20667dfd05a --- /dev/null +++ b/plutus-ledger-api/src/PlutusLedgerApi/V3/MintValue.hs @@ -0,0 +1,126 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE DeriveAnyClass #-} +{-# LANGUAGE DeriveDataTypeable #-} +{-# LANGUAGE DerivingVia #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE TypeApplications #-} +{-# LANGUAGE TypeFamilies #-} +{-# OPTIONS_GHC -fexpose-all-unfoldings #-} +{-# OPTIONS_GHC -fno-omit-interface-pragmas #-} +{-# OPTIONS_GHC -fno-spec-constr #-} +{-# OPTIONS_GHC -fno-specialise #-} + +module PlutusLedgerApi.V3.MintValue + ( MintValue (..) -- Constructor is exported for testing + , emptyMintValue + , mintValueToMap + , mintValueMinted + , mintValueBurned + ) +where + +import PlutusTx.Prelude + +import Control.DeepSeq (NFData) +import Data.Data (Data, Typeable) +import GHC.Generics (Generic) +import PlutusLedgerApi.V1.Value (CurrencySymbol, TokenName, Value (..)) +import PlutusTx (FromData (..), ToData (..), UnsafeFromData (..)) +import PlutusTx.AssocMap (Map) +import PlutusTx.AssocMap qualified as Map +import PlutusTx.Blueprint.Class (HasBlueprintSchema (..)) +import PlutusTx.Blueprint.Definition (HasBlueprintDefinition (..), definitionIdFromType, + definitionRef) +import PlutusTx.Blueprint.Schema (MapSchema (..), Schema (..)) +import PlutusTx.Blueprint.Schema.Annotation (emptySchemaInfo, title) +import PlutusTx.Lift (makeLift) +import Prelude qualified as Haskell +import Prettyprinter (Pretty) +import Prettyprinter.Extras (PrettyShow (PrettyShow)) + +{- Note [MintValue vs Value] + +'MintValue' differs conceptually from 'Value' in how negative quantities are interpreted: + +In 'MintValue', negative quantities are interpreted as assets being burned. For 'Value', +negative quantities are either don't make sense (e.g. in a transaction output) or interpreted +as a negative balance. + +We want to distinguish these at the type level to avoid using 'MintValue' where 'Value' is assumed. +Users should project 'MintValue' into 'Value' using 'mintValueMinted' or 'mintValueBurned'. +-} + +-- | A 'MintValue' represents assets that are minted and burned in a transaction. +newtype MintValue = UnsafeMintValue (Map CurrencySymbol (Map TokenName Integer)) + deriving stock (Generic, Data, Typeable, Haskell.Show) + deriving anyclass (NFData) + deriving newtype (ToData, FromData, UnsafeFromData) + deriving (Pretty) via (PrettyShow MintValue) + +instance Haskell.Eq MintValue where + l == r = mintValueMinted l == mintValueMinted r && mintValueBurned l == mintValueBurned r + +instance HasBlueprintDefinition MintValue where + type Unroll MintValue = '[MintValue, CurrencySymbol, TokenName, Integer] + definitionId = definitionIdFromType @MintValue + +instance HasBlueprintSchema MintValue referencedTypes where + {-# INLINEABLE schema #-} + schema = + SchemaMap + emptySchemaInfo{title = Just "MintValue"} + MkMapSchema + { keySchema = definitionRef @CurrencySymbol + , valueSchema = + SchemaMap + emptySchemaInfo + MkMapSchema + { keySchema = definitionRef @TokenName + , valueSchema = definitionRef @Integer + , minItems = Nothing + , maxItems = Nothing + } + , minItems = Nothing + , maxItems = Nothing + } + +{-# INLINEABLE emptyMintValue #-} +emptyMintValue :: MintValue +emptyMintValue = UnsafeMintValue Map.empty + +{-# INLINEABLE mintValueToMap #-} +mintValueToMap :: MintValue -> Map CurrencySymbol (Map TokenName Integer) +mintValueToMap (UnsafeMintValue m) = m + +-- | Get the 'Value' minted by the 'MintValue'. +{-# INLINEABLE mintValueMinted #-} +mintValueMinted :: MintValue -> Value +mintValueMinted (UnsafeMintValue values) = filterQuantities (\x -> [x | x > 0]) values + +{- | Get the 'Value' burned by the 'MintValue'. +All the negative quantities in the 'MintValue' become positive in the resulting 'Value'. +-} +{-# INLINEABLE mintValueBurned #-} +mintValueBurned :: MintValue -> Value +mintValueBurned (UnsafeMintValue values) = filterQuantities (\x -> [abs x | x < 0]) values + +{-# INLINEABLE filterQuantities #-} +filterQuantities :: (Integer -> [Integer]) -> Map CurrencySymbol (Map TokenName Integer) -> Value +filterQuantities mapQuantity values = + Value (Map.unsafeFromList (foldr filterTokenQuantities [] (Map.toList values))) + where + {-# INLINEABLE filterTokenQuantities #-} + filterTokenQuantities + :: (CurrencySymbol, Map TokenName Integer) + -> [(CurrencySymbol, Map TokenName Integer)] + -> [(CurrencySymbol, Map TokenName Integer)] + filterTokenQuantities (currency, tokenQuantities) = + case concatMap (traverse mapQuantity) (Map.toList tokenQuantities) of + [] -> id + quantities -> ((currency, Map.unsafeFromList quantities) :) + +---------------------------------------------------------------------------------------------------- +-- TH Splices -------------------------------------------------------------------------------------- + +$(makeLift ''MintValue) diff --git a/plutus-ledger-api/test-plugin/Spec/ScriptSize.hs b/plutus-ledger-api/test-plugin/Spec/ScriptSize.hs index 2f9a948b89a..e5b1466de0f 100644 --- a/plutus-ledger-api/test-plugin/Spec/ScriptSize.hs +++ b/plutus-ledger-api/test-plugin/Spec/ScriptSize.hs @@ -16,6 +16,7 @@ import PlutusCore.Evaluation.Machine.ExBudgetingDefaults (defaultCekParametersFo import PlutusCore.StdLib.Data.Unit (unitval) import PlutusLedgerApi.V2 qualified as V2 import PlutusLedgerApi.V3 qualified as V3 +import PlutusLedgerApi.V3.MintValue (emptyMintValue) import PlutusTx (CompiledCode, liftCodeDef, unsafeApplyCode) import PlutusTx.AssocMap qualified as Map import PlutusTx.Builtins.Internal qualified as BI @@ -164,7 +165,7 @@ dummyScriptContext = , V3.txInfoReferenceInputs = [] , V3.txInfoOutputs = [] , V3.txInfoFee = 1000000 :: V3.Lovelace - , V3.txInfoMint = mempty + , V3.txInfoMint = emptyMintValue , V3.txInfoTxCerts = [] , V3.txInfoWdrl = Map.empty , V3.txInfoValidRange = diff --git a/plutus-ledger-api/test/Spec.hs b/plutus-ledger-api/test/Spec.hs index 772faf953f5..dfabde4319d 100644 --- a/plutus-ledger-api/test/Spec.hs +++ b/plutus-ledger-api/test/Spec.hs @@ -20,6 +20,7 @@ import Spec.Interval qualified import Spec.ScriptDecodeError qualified import Spec.V1.Data.Value qualified as Data.Value import Spec.V1.Value qualified as Value +import Spec.V3.MintValue qualified as MintValue import Spec.Versions qualified import Test.Tasty @@ -136,6 +137,7 @@ tests = testGroup "plutus-ledger-api" , Spec.CostModelParams.tests , Spec.ContextDecoding.tests , Value.test_Value + , MintValue.tests ] , testGroup "Data" [ Spec.Data.Eval.tests diff --git a/plutus-ledger-api/test/Spec/V1/Value.hs b/plutus-ledger-api/test/Spec/V1/Value.hs index 422bc740752..1f817bbed15 100644 --- a/plutus-ledger-api/test/Spec/V1/Value.hs +++ b/plutus-ledger-api/test/Spec/V1/Value.hs @@ -1,5 +1,3 @@ -{-# LANGUAGE MultiWayIf #-} - module Spec.V1.Value where import PlutusLedgerApi.Test.V1.Value as Value diff --git a/plutus-ledger-api/test/Spec/V3/MintValue.hs b/plutus-ledger-api/test/Spec/V3/MintValue.hs new file mode 100644 index 00000000000..ab9eb0042ff --- /dev/null +++ b/plutus-ledger-api/test/Spec/V3/MintValue.hs @@ -0,0 +1,63 @@ +{-# LANGUAGE BlockArguments #-} + +module Spec.V3.MintValue where + +import Data.Set (Set) +import Data.Set qualified as Set +import PlutusLedgerApi.Test.V1.Value () +import PlutusLedgerApi.Test.V3.MintValue () +import PlutusLedgerApi.V1.Value (AssetClass (..), Value (..), flattenValue) +import PlutusLedgerApi.V3.MintValue (MintValue, mintValueBurned, mintValueMinted) +import PlutusTx.AssocMap qualified as Map +import PlutusTx.IsData.Class (toBuiltinData) +import Spec.V1.Data.Value (scaleTestsBy) +import Test.Tasty (TestTree, testGroup) +import Test.Tasty.QuickCheck (testProperty, (===)) +import Unsafe.Coerce (unsafeCoerce) + +tests :: TestTree +tests = + testGroup + "MintValue" + [ test_MintValueBuiltinData + , test_AssetClassIsEitherMintedOrBurned + , test_MintValueMintedIsPositive + , test_MintValueBurnedIsPositive + ] + +test_MintValueBuiltinData :: TestTree +test_MintValueBuiltinData = + testProperty "Builtin data representation of MintValue and Value is the same" $ + scaleTestsBy 5 \(values :: Either Value MintValue) -> do + let (value, mintValue) = + case values of + Left v -> (v, unsafeCoerce v) + Right mv -> (unsafeCoerce mv, mv) + toBuiltinData mintValue === toBuiltinData value + +test_AssetClassIsEitherMintedOrBurned :: TestTree +test_AssetClassIsEitherMintedOrBurned = + testProperty "Asset class is either minted or burned" $ + scaleTestsBy 5 \(mintValue :: MintValue) -> + Set.null $ + Set.intersection + (valueAssetClasses (mintValueMinted mintValue)) + (valueAssetClasses (mintValueBurned mintValue)) + where + valueAssetClasses :: Value -> Set AssetClass + valueAssetClasses value = + Set.fromList [AssetClass (cs, tn) | (cs, tn, _q) <- flattenValue value] + +test_MintValueMintedIsPositive :: TestTree +test_MintValueMintedIsPositive = + testProperty "MintValue minted is positive" $ + scaleTestsBy 5 \(mintValue :: MintValue) -> + let Value minted = mintValueMinted mintValue + in all (all (> 0) . Map.elems) (Map.elems minted) + +test_MintValueBurnedIsPositive :: TestTree +test_MintValueBurnedIsPositive = + testProperty "MintValue burned is positive" $ + scaleTestsBy 5 \(mintValue :: MintValue) -> + let Value burned = mintValueBurned mintValue + in all (all (> 0) . Map.elems) (Map.elems burned) diff --git a/plutus-ledger-api/testlib/PlutusLedgerApi/Test/V3/MintValue.hs b/plutus-ledger-api/testlib/PlutusLedgerApi/Test/V3/MintValue.hs new file mode 100644 index 00000000000..f8f87b39ad9 --- /dev/null +++ b/plutus-ledger-api/testlib/PlutusLedgerApi/Test/V3/MintValue.hs @@ -0,0 +1,44 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE KindSignatures #-} +{-# LANGUAGE TypeApplications #-} +{-# OPTIONS_GHC -Wno-orphans #-} + +module PlutusLedgerApi.Test.V3.MintValue where + +import Data.Coerce (coerce) +import PlutusCore.Generators.QuickCheck.Split (multiSplit0) +import PlutusLedgerApi.Test.V1.Value (NoArbitrary (..), uniqueNames) +import PlutusLedgerApi.V1.Value (CurrencySymbol (..), TokenName (..)) +import PlutusLedgerApi.V3.MintValue (MintValue (..)) +import PlutusTx.AssocMap qualified as Map +import PlutusTx.List qualified as List +import Test.QuickCheck (Arbitrary (..)) + +instance Arbitrary MintValue where + arbitrary = do + -- Generate values for all of the 'TokenName's in the final 'MintValue' + -- and split them into a list of lists. + faceValues <- multiSplit0 0.2 . map unQuantity =<< arbitrary + -- Generate 'TokenName's and 'CurrencySymbol's. + currencies <- + uniqueNames CurrencySymbol + =<< traverse (uniqueNames TokenName) faceValues + pure $ listsToMintValue currencies + + shrink = + map listsToMintValue + . coerce + (shrink @[(NoArbitrary CurrencySymbol, [(NoArbitrary TokenName, Integer)])]) + . mintValueToLists + +-- | Convert a list representation of a 'MintValue' to the 'MintValue'. +listsToMintValue :: [(CurrencySymbol, [(TokenName, Integer)])] -> MintValue +listsToMintValue = coerce . Map.unsafeFromList . List.map (fmap Map.unsafeFromList) + +-- | Convert a 'MintValue' to its list representation. +mintValueToLists :: MintValue -> [(CurrencySymbol, [(TokenName, Integer)])] +mintValueToLists = List.map (fmap Map.toList) . Map.toList . coerce + +newtype Quantity = Quantity {unQuantity :: Integer} + deriving newtype (Arbitrary, Show)