-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[Bug] Signature created outside VM is not valid in circuit #2007
Comments
See this comment for a sample usage. |
Sorry @d0cd this is not helpful |
@onetrickwolf see the above discussion, do we have an existing example or test of creating a signature using the SDK's |
The SDK code for signing runs the signature algorithm outside of the context of a circuit. However when running a circuit via a leo function, and given the function executes properly and gives you a What I imagine is happening here is that Leo types like const bytes = textEncoder.encode('123Field')
const sign = account.sign(bytes) The code above will create utf-8 bytes which will lead to a different byte encoding than the 123Field type within Leo. And this why this function is likely failing:
Currently there's not yet a function that will first try to serialize these types into the correct byte encoding in the SDK, but I'll put a ticket in to support this. |
@iamalwaysuncomfortable I've traced what the word 'test' turns into when being signed and it turns into field |
To confirm, 1953719668 is 0x74736574 which when turned to bytes gets you 'tset' which is 'test' in LE |
Can you post your Leo code + the |
Sure @iamalwaysuncomfortable it's the same code that's in the first message though
hello.aleo
command
and its output
|
🐛 Bug Report
Hey, I'm trying to sign an arbitrary string (byte array) outside VM (in SDK) and validate it inside Aleo transition but it always fails.
Steps to Reproduce
First, I convert a string to a field in the same way it's done in VM:
(i'm tapping into aleo-wasm, also new to Rust, so my code is not perfect)
the resulting field is
1953719668field
When I use SDK I just do
The example signature for the following private key
APrivateKey1zkp5gkX61etNqNTibpEaZD7tC8FJV2NxYQQtwyzKgGY9vwD
and its address
aleo1zen02agt7udrz24ffqddfe633s8cuecjy4p4qg03p5vfukvrjqfqvx2tyc
and the string/field above is :
sign1mdks5v7yypepq6dqpk0zw3vlq3dha7l9wq6eghjdyvg8ehpwxgp7x0sj2mkhj9ywd5qltt7nuaeg55drmglju3p6uq97w5qfejlg6pr9c6pajt957g355dkue2l8mq00x7ur3zrlavsnvzyradh6kkcrqdpvfyd7pzwmn5s6f2v0mh6qcf92sqx7ng8lnxraqufle0dvkq2pz7na86y
which is valid if I verify in in both SDK and in sample Rust code
It's also valid if I verify it against field itself:
BUT
If I put it in leo transition:
with these inputs:
It returns false
I'm out of ideas, maybe you have any
The text was updated successfully, but these errors were encountered: