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 fractional difficulty #3

Open
vkoskiv opened this issue Jan 10, 2018 · 9 comments
Open

Implement fractional difficulty #3

vkoskiv opened this issue Jan 10, 2018 · 9 comments

Comments

@vkoskiv
Copy link
Owner

vkoskiv commented Jan 10, 2018

Swift can't deal with 256 bit UInts natively, so figure out how to implement this.
Without fractional difficulty, difficulty can only double or halve, which is inconvenient given difficulty will be adjusted hourly.

@vkoskiv
Copy link
Owner Author

vkoskiv commented Jan 10, 2018

@johndpope
Copy link
Contributor

@johndpope
Copy link
Contributor

@vkoskiv
Copy link
Owner Author

vkoskiv commented Jan 10, 2018

The project currently has the file UInt+SHA256.swift that implements most of the required functionality for working with 256 bit block hashes. However, I recently discovered it lacks multiple operands, most notably division and multiplication. (You can observe the //TODO lines in the file)
I forgot where I found the file, so we'll have to find another implementation.

@vkoskiv
Copy link
Owner Author

vkoskiv commented Jan 10, 2018

I don't particularly like CryptoCoinSwift's implementation, since it relies on C functions to do many operations. I'd only implement it if Swift 3 really has performance issues with those operations.

@johndpope
Copy link
Contributor

johndpope commented Jan 10, 2018

glancing through feeds
"if you're doing crypto, you're probably safer using NSDecimalNumber, is what we use for Toshi. " https://github.com/toshiapp/toshi-ios-client/blob/32f05c83b1ba7c383aaa1f0a18565df544688fe1/Toshi/Extensions/NSDecimalNumber%2BAdditions.swift

screen shot 2018-01-10 at 12 11 48 pm

@vkoskiv
Copy link
Owner Author

vkoskiv commented Jan 10, 2018

Personally I'm a bit lost currently on how we'll implement the difficulty. I'm tempted to just go with hashcash's fixed number of bits for now.

@slk333
Copy link

slk333 commented Jan 11, 2018

you can try with NSDecimalNumber, it has 128 bit precision, and can store number up to 512 bit
https://developer.apple.com/documentation/foundation/nsdecimalnumber

@vkoskiv
Copy link
Owner Author

vkoskiv commented Jan 11, 2018

@slk333 We need 256 bits for SHA256

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

No branches or pull requests

3 participants