shannon entropy calculation and script type matching#335
shannon entropy calculation and script type matching#335cc-unchained wants to merge 2 commits intocaravan-bitcoin:mainfrom
Conversation
|
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
bucko13
left a comment
There was a problem hiding this comment.
This is awesome. Thanks for putting together. I'd love to merge this in if we can. Just a couple of relatively minor comments.
|
|
||
| it("can measure amount entropy", () => { | ||
| const result = amountFingerprints(["40.8199902", "1.18000000"]); | ||
| expect(result).toEqual([true, false]); |
There was a problem hiding this comment.
is the idea that there is always one (and only one) value that will be true?
| const maxEntropy = Math.max(...entropies); | ||
|
|
||
| // Mark true if this output has the maximum entropy | ||
| return entropies.map((e) => e === maxEntropy); |
There was a problem hiding this comment.
If you have a "perfect spend" transaction that has 1 output, then this will always return [ true ]. Is this desirable? Maybe yes, maybe no. I can't decide 😅. Maybe if it's length 1, it should be [ false ]?
| }, 0); | ||
| } | ||
|
|
||
| export function amountFingerprints(amounts: string[]): boolean[] { |
There was a problem hiding this comment.
would you mind adding docstrings to this to explain what's being solved here and in particular to describe how to interpret the output.
|
This pull request has been inactive for 30 days and has been marked as stale. It will be closed in 7 days if no further activity occurs. To keep this PR open, add the "long-lived" label or comment on it. |
What kind of change does this PR introduce?
POC implementation of entropy calculation for output amounts. Side-steps the complexity of obtaining prevout address information from outpoints.
For follow up work addressing the above, a z-score calculation may be of interest.
https://en.wikipedia.org/wiki/Standard_score
Issue Number:
#317
Snapshots/Videos:
If relevant, did you update the documentation?
Summary
Does this PR introduce a breaking change?
Checklist
npm run changeset)Other information
Have you read the contributing guide?
For information on creating and using changesets, please refer to our documentation on changesets.