-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
2879 tzip32 doc #2994
Merged
Merged
2879 tzip32 doc #2994
Changes from 39 commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
81f82f7
Merge branch 'master' of https://github.com/ecadlabs/taquito
hui-an-yang eab82bb
Merge branch 'master' of https://github.com/ecadlabs/taquito
hui-an-yang 0259cdd
Merge branch 'master' of https://github.com/ecadlabs/taquito
hui-an-yang b1a2679
Merge branch 'master' of https://github.com/ecadlabs/taquito
hui-an-yang 45223bd
Merge branch 'master' of https://github.com/ecadlabs/taquito
hui-an-yang a82b5cd
Merge branch 'master' of https://github.com/ecadlabs/taquito
hui-an-yang 3b08821
Merge branch 'master' of https://github.com/ecadlabs/taquito
hui-an-yang bfd1f49
Merge branch 'master' of https://github.com/ecadlabs/taquito
hui-an-yang 5d0a7cc
Merge branch 'master' of https://github.com/ecadlabs/taquito
hui-an-yang 7b9d4c1
Merge branch 'master' of https://github.com/ecadlabs/taquito
hui-an-yang 37e14e4
Merge branch 'master' of https://github.com/ecadlabs/taquito
hui-an-yang dc68be9
Merge branch 'master' of https://github.com/ecadlabs/taquito
hui-an-yang f259810
Merge branch 'master' of https://github.com/ecadlabs/taquito
hui-an-yang 6fdda51
Merge branch 'master' of https://github.com/ecadlabs/taquito
hui-an-yang 298b413
Merge branch 'master' of https://github.com/ecadlabs/taquito
hui-an-yang 06af53b
Merge branch 'master' of https://github.com/ecadlabs/taquito
hui-an-yang e4853cf
Merge branch 'master' of https://github.com/ecadlabs/taquito
hui-an-yang fc2e2b0
Merge branch 'master' of https://github.com/ecadlabs/taquito
hui-an-yang a64564e
Merge branch 'master' of https://github.com/ecadlabs/taquito
hui-an-yang ae561ab
Merge branch 'master' of https://github.com/ecadlabs/taquito
hui-an-yang 0a2974b
Merge branch 'master' of https://github.com/ecadlabs/taquito
hui-an-yang 708d150
Merge branch 'master' of https://github.com/ecadlabs/taquito
hui-an-yang e018e9e
Merge branch 'master' of https://github.com/ecadlabs/taquito
hui-an-yang 4523ffb
Merge branch 'master' of https://github.com/ecadlabs/taquito
hui-an-yang 3c386ad
Merge branch 'master' of https://github.com/ecadlabs/taquito
hui-an-yang dffb59c
Merge branch 'master' of https://github.com/ecadlabs/taquito
hui-an-yang b58a460
Merge branch 'master' of https://github.com/ecadlabs/taquito
hui-an-yang 8fa69af
Merge branch 'master' of https://github.com/ecadlabs/taquito
hui-an-yang a896a23
Merge branch 'master' of https://github.com/ecadlabs/taquito
hui-an-yang fd47258
Merge branch 'master' of https://github.com/ecadlabs/taquito
hui-an-yang 00892e8
Merge branch 'master' of https://github.com/ecadlabs/taquito
hui-an-yang a39aaa5
Merge branch 'master' of https://github.com/ecadlabs/taquito
hui-an-yang 82f5a89
Merge branch 'master' of https://github.com/ecadlabs/taquito
hui-an-yang bbaba4b
Merge branch 'master' of https://github.com/ecadlabs/taquito
hui-an-yang 47324c0
Merge branch 'master' of https://github.com/ecadlabs/taquito
hui-an-yang f1c5423
Merge branch 'master' of https://github.com/ecadlabs/taquito
hui-an-yang 8541658
Merge branch 'master' of https://github.com/ecadlabs/taquito
hui-an-yang 4037e50
Merge branch 'master' of https://github.com/ecadlabs/taquito
hui-an-yang f93802e
docs: tzip-32 signing documentation
hui-an-yang 34a19ca
docs: updated examples in tab and and v20 versioned docs
hui-an-yang ebb5db4
docs: addressed review comments
hui-an-yang 17d4711
test: add signing.md file changes
hui-an-yang 9f4a145
Merge branch 'master' of https://github.com/ecadlabs/taquito into 287…
hui-an-yang 42b1ef7
test: fixing integration test
hui-an-yang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -141,6 +141,87 @@ const isVerified = verifySignature( | |
); | ||
``` | ||
|
||
## Generating a tzip-32 message signature | ||
|
||
The community have proposed [tzip-32](https://gitlab.com/tezos/tzip/-/blob/71be45d3ae2e15cec5c7a2f84feb88aac58fbe5e/drafts/current/draft-message-signing/tzip-32.md)(draft), Off-Chain Message Signing, which aims to define a formal message signing standard that is simple, secure, extendable and compatible with hardware wallets. Tzip-32 can be further used in [tzip-33](https://gitlab.com/tezos/tzip/-/blob/6483efc9e591960effe76f4ae996ec187bf13bf4/drafts/current/draft-sign-in-with-tezos.md)(draft) which is a [caip-122](https://chainagnostic.org/CAIPs/caip-122) compliant sign-in with Tezos standard. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also let's capitalize CAIP-122 |
||
|
||
**Message encoding** | ||
|
||
This is the schema to encode the message into bytes, please read the [tzip-32](https://gitlab.com/tezos/tzip/-/blob/71be45d3ae2e15cec5c7a2f84feb88aac58fbe5e/drafts/current/draft-message-signing/tzip-32.md) for more detail. | ||
|
||
| Name | Size | Contents | | ||
|-----------------------|----------|-------------------------| | ||
| magic_string | 30 bytes | bytes | | ||
| # Bytes in next field | 1 byte | unsigned 8-bit integer | | ||
| interface | variable | bytes | | ||
| character_encoding | 1 byte | unsigned 8-bit integer | | ||
| # Bytes in next field | 2 bytes | unsigned 16-bit integer | | ||
| message | Variable | bytes | | ||
|
||
|
||
<Tabs | ||
defaultValue="contractAPI" | ||
values={[ | ||
{label: 'Contract API', value: 'contractAPI'}, | ||
{label: 'Wallet API', value: 'walletAPI'} | ||
]}> | ||
<TabItem value="contractAPI"> | ||
|
||
|
||
The Off-Chain Message Signing magic bytes is `0x80` defined in [tzip-31](https://gitlab.com/tezos/tzip/-/blob/71be45d3ae2e15cec5c7a2f84feb88aac58fbe5e/drafts/current/draft-signer-requests/tzip-31.md)(draft). | ||
|
||
```js live noInline | ||
// import { TezosToolkit } from '@taquito/taquito' | ||
// import { InMemorySigner } from '@taquito/signer' | ||
// import { stringToBytes, num2PaddedHex } from '@taquito/utils'; | ||
// const Tezos = new TezosToolkit('https://ghostnet.ecadinfra.com'); | ||
|
||
let magicByte = '0x80' | ||
let magicString = 'tezos signed offchain message' | ||
let interface_ = 'tzip://32' | ||
let characterEncoding = '0' | ||
let message = 'Hello world!' | ||
|
||
let bytes = stringToBytes(magicString) + num2PaddedHex(interface_.length, 8) + stringToBytes(interface_) + num2PaddedHex(Number(characterEncoding), 8) + num2PaddedHex(message.length, 16) + stringToBytes(message) | ||
|
||
InMemorySigner.fromSecretKey('edsk2rKA8YEExg9Zo2qNPiQnnYheF1DhqjLVmfKdxiFfu5GyGRZRnb') | ||
.then((theSigner) => { | ||
Tezos.setProvider({ signer: theSigner }); | ||
return Tezos.signer.sign(bytes, new Uint8Array([parseInt(magicByte, 16)])) | ||
}) | ||
.then(signed => { | ||
println(JSON.stringify(signed, null, 2)); | ||
}) | ||
.catch((error) => println(`Error: ${error} ${JSON.stringify(error, null, 2)}`)); | ||
``` | ||
|
||
</TabItem> | ||
<TabItem value="walletAPI"> | ||
|
||
```js live noInline wallet | ||
// import { TezosToolkit } from '@taquito/taquito' | ||
// import { InMemorySigner } from '@taquito/signer' | ||
// import { stringToBytes, num2PaddedHex } from '@taquito/utils'; | ||
// const Tezos = new TezosToolkit('https://ghostnet.ecadinfra.com'); | ||
|
||
let magicByte = '0x80' | ||
let magicString = 'tezos signed offchain message' | ||
let interface_ = 'tzip://32' | ||
let characterEncoding = '0' | ||
let message = 'Hello world!' | ||
|
||
let bytes = stringToBytes(magicString) + num2PaddedHex(interface_.length, 8) + stringToBytes(interface_) + num2PaddedHex(characterEncoding, 8) + num2PaddedHex(message.length, 16) + stringToBytes(message) | ||
|
||
const payload = { | ||
signingType: SigningType.RAW, | ||
payload: magicByte + bytes | ||
} | ||
wallet.client.requestSignPayload(payload).then(signed => println(JSON.stringify(signed, null, 2))) | ||
``` | ||
|
||
</TabItem> | ||
</Tabs> | ||
|
||
## Signing Michelson data | ||
|
||
Taquito also offers the possibility to sign Michelson code. This feature can be useful, for example, if you need to send a lambda to a contract to be executed but want to restrict the number of users who can submit a lambda by verifying the signer's address. The signing of Michelson code requires the use of the `michel-codec` package: | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is a good idea to capitalize to Tzip-32 here and everywhere else