-
Notifications
You must be signed in to change notification settings - Fork 478
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
Is it possible to add a cheaper way to get hash from Plutus data? #6524
Comments
And you are not satisfied with that and believe that it can be improved somehow? How? I think It's So I'm not sure what you're proposing here. |
Thanks for your the answer, I think I see what you're talking about.
I was looking for answers here on where to find performance for not very meaningful conversions to Data and Cborg.
It seems to me that beta-equality is not very important in such cases and is not a very unsafe thing.
Perhaps I don't fully understand why breaking parametricity is a problem for a user who wants to take responsibility.
🤔 |
I'm assuming the code you are interested in optimizing is from here The vast majority of the budget from this contract is consumed by the conversion of the script context from and to data encoding. symbolicVerifier :: SetupBytes -> ProofBytes -> ScriptContext -> Bool
symbolicVerifier contract proof ctx = ...
info = scriptContextTxInfo ctx
ins = txInfoInputs info
refs = txInfoReferenceInputs info
outs = txInfoOutputs info
range = txInfoValidRange info
hash = blake2b_224 . serialiseData . toBuiltinData $ (ins, refs, outs, range) To symbolicVerifier :: SetupBytes -> BuiltinData -> BuiltinUnit
symbolicVerifier contract ctx =
-- Verifying the Plonk `proof` for the `contract` on the transaction data encoded as `input`
verify @PlonkPlutus @HaskellCore contract input proof
where
ctxFields = BI.snd (BI.unsafeDataAsConstr ctx)
info = BI.head ctxFields
-- Extract redeemer from ScriptContext
proof = unsafeFromBuiltinData @SetupBytes (BI.head $ BI.tail ctxFields)
-- Extracting transaction data
infoFields = BI.snd (BI.unsafeDataAsConstr (BI.head ctxFields))
ins = BI.head infoFields
info_before_ref_inputs = BI.tail txInfo
refs = BI.head info_before_ref_inputs
info_before_outputs = BI.tail info_before_ref_inputs
outs = BI.head info_before_outputs
range = BI.head BI.tail $ BI.tail $ BI.tail $ BI.tail $ BI.tail info_before_outputs
-- Computing public input from the transaction data
txData = BI.mkConstr ins $ BI.mkCons refs $ BI.mkCons outs $ BI.mkConstr range $ BI.mkNilData BI.unitval
input = toInput . blake2b_224 . serialiseData $ txData |
Thank you very much, I really missed this optimization path. |
Describe the feature you'd like
I would like to have a feature like this
(I would also like the hash to fit into 28 bytes)
I think it's worth clarifying the context.
Describe alternatives you've considered
For now I use the following implementation
The text was updated successfully, but these errors were encountered: