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

Implement conversion from Long-encoded nBits representation to BigInt and back #675

Open
kushti opened this issue Jul 30, 2020 · 4 comments
Labels
A-consensus Area: Code used in consensus (i.e. transaction validation) Bounty - 200 SigUSD C-feature Category: Feature request or PR P2-medium Priority: Medium soft-fork Implementation requires soft-fork
Milestone

Comments

@kushti
Copy link
Member

kushti commented Jul 30, 2020

For trustless mining derivatives (see e.g. this proposal https://www.ergoforum.org/t/mining-power-derivatives-two-tokens-approach/277 ) it could be good to have difficulty encoded as a big integer, but currently it is represented in nBits format (as Long value) in the context, which is not suitable for comparisons.

Thus it would be reasonable to implement fromNBits operation, converting nBits in Long value to BigInt.

nBits encoding implementation and corresponding test vectors can be found in the Ergo node codebase.

@kushti kushti added the hard-fork Implementation requires hard-fork label Jul 30, 2020
@kushti kushti added this to the v4.0 milestone Jul 30, 2020
@aslesarenko
Copy link
Member

@kushti Is it AutolykosPowScheme.getB method you are referring to?

@aslesarenko aslesarenko added A-consensus Area: Code used in consensus (i.e. transaction validation) C-feature Category: Feature request or PR P2-medium Priority: Medium soft-fork Implementation requires soft-fork and removed hard-fork Implementation requires hard-fork labels Sep 9, 2020
@aslesarenko aslesarenko modified the milestones: v4.0, v4.x, v6.0, v5.0 Sep 9, 2020
@aslesarenko aslesarenko added the 4h Approximately 4 hours of work label Sep 11, 2020
@aslesarenko aslesarenko changed the title Implement conversion from Long-encoded nBits representation of a big number to BigInt Implement conversion from Long-encoded nBits representation to BigInt Sep 11, 2020
@aslesarenko aslesarenko modified the milestones: v5.0, v6.0 Apr 4, 2021
@kushti
Copy link
Member Author

kushti commented Dec 23, 2022

@kushti
Copy link
Member Author

kushti commented Dec 23, 2022

@aslesarenko In the reference client code, nbits <-> bigint conversion done in RequiredDifficulty.encodeCompactBits / RequiredDifficulty.decodeCompactBits

@kushti kushti changed the title Implement conversion from Long-encoded nBits representation to BigInt Implement conversion from Long-encoded nBits representation to BigInt and back Mar 29, 2024
@kushti kushti added Bounty - 200 SigUSD and removed 4h Approximately 4 hours of work labels Apr 15, 2024
@kushti
Copy link
Member Author

kushti commented Apr 15, 2024

Encoding done in #962

The bounty assigned for decoding part (which would be a dedicated PR)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-consensus Area: Code used in consensus (i.e. transaction validation) Bounty - 200 SigUSD C-feature Category: Feature request or PR P2-medium Priority: Medium soft-fork Implementation requires soft-fork
Projects
None yet
Development

No branches or pull requests

2 participants