Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Native Token name length restriction of 32 bytes #1

Open
ullamonster opened this issue Dec 4, 2021 · 0 comments
Open

Native Token name length restriction of 32 bytes #1

ullamonster opened this issue Dec 4, 2021 · 0 comments

Comments

@ullamonster
Copy link
Contributor

ullamonster commented Dec 4, 2021

To address this limitation in the name length, the pubkeyhash is split into two parts, the last 32 bytes becoming the CATs name. The other 24 bytes are stored in the datum and upon validation, the smartcontract combines these two parts to validate against the signing wallet sig as well as compares both cats to each other and their destination wallet must match the owner.

Here is the first CAT on testnet for our Alice: addr_test1vzck0zlwql2nf7clg5vsxcpucmpg43wvm2srg38vu7hvqsgl9zcer and this associate pubkeyhash is: b1678bee07d534fb1f451903603cc6c28ac5ccdaa03444ece7aec041, the final 32 bytes of which are the name for her 1M CATs seen at the above address.

The smartcontract should be able to handle logic like so:

These values need to be found

  • pubKeyExpect = this tx signer pubkeyhash
  • catNameExpect = final 32 bytes of pubKeyExpect
  • pubKeyPrefixExpect = Datum stored first 24 bytes of the pubkeyhash who locked the funds/filled the datum
  • pubKeyReconstruct = pubKeyPrefixExpect + catNameExpect

With these values we do this logic, all of which must be true in order to validate:

  • Does tx-in from script have 1 CAT with catNameExpect
  • Does tx-in from signer have 1 CAT with catNameExpect
  • Does pubKeyExpect =match= pubKeyReconstruct
  • Do CATs match
  • Are CATs being spent to pubKeyExpect

If these conditions are met, the transaction is valid. It would be pointless in most instances to try to change the datum with this configuration as you would be creating a hash that cannot work for validation, locking the funds forever. So while unlocking still relies on datum in this situation, it won't allow unlocking by someone who modified the datum via a webapp.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant