nanocurrency 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +11 -0
  3. data/.rspec +3 -0
  4. data/.travis.yml +7 -0
  5. data/CODE_OF_CONDUCT.md +74 -0
  6. data/Gemfile +6 -0
  7. data/Gemfile.lock +40 -0
  8. data/LICENSE.txt +21 -0
  9. data/README.md +43 -0
  10. data/Rakefile +16 -0
  11. data/bin/console +14 -0
  12. data/bin/setup +8 -0
  13. data/ext/.DS_Store +0 -0
  14. data/ext/nanocurrency_ext/blake2-config.h +72 -0
  15. data/ext/nanocurrency_ext/blake2-impl.h +160 -0
  16. data/ext/nanocurrency_ext/blake2.h +195 -0
  17. data/ext/nanocurrency_ext/blake2b-load-sse2.h +68 -0
  18. data/ext/nanocurrency_ext/blake2b-load-sse41.h +402 -0
  19. data/ext/nanocurrency_ext/blake2b-ref.c +373 -0
  20. data/ext/nanocurrency_ext/blake2b-round.h +157 -0
  21. data/ext/nanocurrency_ext/curve25519-donna-32bit.h +579 -0
  22. data/ext/nanocurrency_ext/curve25519-donna-64bit.h +413 -0
  23. data/ext/nanocurrency_ext/curve25519-donna-helpers.h +67 -0
  24. data/ext/nanocurrency_ext/curve25519-donna-sse2.h +1112 -0
  25. data/ext/nanocurrency_ext/ed25519-donna-32bit-sse2.h +513 -0
  26. data/ext/nanocurrency_ext/ed25519-donna-32bit-tables.h +61 -0
  27. data/ext/nanocurrency_ext/ed25519-donna-64bit-sse2.h +436 -0
  28. data/ext/nanocurrency_ext/ed25519-donna-64bit-tables.h +53 -0
  29. data/ext/nanocurrency_ext/ed25519-donna-64bit-x86-32bit.h +435 -0
  30. data/ext/nanocurrency_ext/ed25519-donna-64bit-x86.h +351 -0
  31. data/ext/nanocurrency_ext/ed25519-donna-basepoint-table.h +259 -0
  32. data/ext/nanocurrency_ext/ed25519-donna-batchverify.h +275 -0
  33. data/ext/nanocurrency_ext/ed25519-donna-impl-base.h +364 -0
  34. data/ext/nanocurrency_ext/ed25519-donna-impl-sse2.h +390 -0
  35. data/ext/nanocurrency_ext/ed25519-donna-portable-identify.h +103 -0
  36. data/ext/nanocurrency_ext/ed25519-donna-portable.h +135 -0
  37. data/ext/nanocurrency_ext/ed25519-donna.h +115 -0
  38. data/ext/nanocurrency_ext/ed25519-hash-custom.c +28 -0
  39. data/ext/nanocurrency_ext/ed25519-hash-custom.h +30 -0
  40. data/ext/nanocurrency_ext/ed25519-hash.h +219 -0
  41. data/ext/nanocurrency_ext/ed25519-randombytes-custom.h +10 -0
  42. data/ext/nanocurrency_ext/ed25519-randombytes.h +91 -0
  43. data/ext/nanocurrency_ext/ed25519.c +150 -0
  44. data/ext/nanocurrency_ext/ed25519.h +30 -0
  45. data/ext/nanocurrency_ext/extconf.rb +3 -0
  46. data/ext/nanocurrency_ext/fuzz/README.md +173 -0
  47. data/ext/nanocurrency_ext/fuzz/build-nix.php +134 -0
  48. data/ext/nanocurrency_ext/fuzz/curve25519-ref10.c +1272 -0
  49. data/ext/nanocurrency_ext/fuzz/curve25519-ref10.h +8 -0
  50. data/ext/nanocurrency_ext/fuzz/ed25519-donna-sse2.c +3 -0
  51. data/ext/nanocurrency_ext/fuzz/ed25519-donna.c +1 -0
  52. data/ext/nanocurrency_ext/fuzz/ed25519-donna.h +34 -0
  53. data/ext/nanocurrency_ext/fuzz/ed25519-ref10.c +4647 -0
  54. data/ext/nanocurrency_ext/fuzz/ed25519-ref10.h +9 -0
  55. data/ext/nanocurrency_ext/fuzz/fuzz-curve25519.c +172 -0
  56. data/ext/nanocurrency_ext/fuzz/fuzz-ed25519.c +219 -0
  57. data/ext/nanocurrency_ext/modm-donna-32bit.h +469 -0
  58. data/ext/nanocurrency_ext/modm-donna-64bit.h +361 -0
  59. data/ext/nanocurrency_ext/rbext.c +164 -0
  60. data/ext/nanocurrency_ext/regression.h +1024 -0
  61. data/lib/nano/account.rb +59 -0
  62. data/lib/nano/base32.rb +87 -0
  63. data/lib/nano/block.rb +142 -0
  64. data/lib/nano/check.rb +65 -0
  65. data/lib/nano/conversion.rb +102 -0
  66. data/lib/nano/hash.rb +43 -0
  67. data/lib/nano/key.rb +69 -0
  68. data/lib/nano/utils.rb +45 -0
  69. data/lib/nano/work.rb +51 -0
  70. data/lib/nanocurrency.rb +7 -0
  71. data/lib/nanocurrency/version.rb +3 -0
  72. data/lib/nanocurrency_ext.bundle +0 -0
  73. data/nanocurrency.gemspec +44 -0
  74. metadata +192 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 31856813e2982b523c6cbd87080416b43d1b1843375af282cce8be90f68f3f8e
4
+ data.tar.gz: 4219b7f198944d4a46fe1269382b5909da85c72e30aa8e89c3b30c7aa0e7a0d7
5
+ SHA512:
6
+ metadata.gz: 53ef55cfdb31e9585d009f6d404d610369ef89ca71f4c4ebf77dd58c1bd16b38926b4e0cd935020500b5eea8e187819ef8c03c89fd80fce548697b54f8852530
7
+ data.tar.gz: 424939d539c3d2a1454eb2c0e7c866a33d3a5ec410e037c07bac5592f2647318a34b0649419854cc27d3a2371c11d9a807532c6a09ff65df2311a569bbf9a761
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.5.1
7
+ before_install: gem install bundler -v 1.16.6
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at elliott.minns@me.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in nanocurrency.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,40 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ nanocurrency (0.1.0)
5
+ blake2b
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ blake2b (0.10.0)
11
+ diff-lcs (1.3)
12
+ rake (10.5.0)
13
+ rake-compiler (1.0.7)
14
+ rake
15
+ rspec (3.8.0)
16
+ rspec-core (~> 3.8.0)
17
+ rspec-expectations (~> 3.8.0)
18
+ rspec-mocks (~> 3.8.0)
19
+ rspec-core (3.8.0)
20
+ rspec-support (~> 3.8.0)
21
+ rspec-expectations (3.8.3)
22
+ diff-lcs (>= 1.2.0, < 2.0)
23
+ rspec-support (~> 3.8.0)
24
+ rspec-mocks (3.8.0)
25
+ diff-lcs (>= 1.2.0, < 2.0)
26
+ rspec-support (~> 3.8.0)
27
+ rspec-support (3.8.0)
28
+
29
+ PLATFORMS
30
+ ruby
31
+
32
+ DEPENDENCIES
33
+ bundler (~> 1.16)
34
+ nanocurrency!
35
+ rake (~> 10.0)
36
+ rake-compiler (~> 1.0)
37
+ rspec (~> 3.0)
38
+
39
+ BUNDLED WITH
40
+ 1.16.6
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Nanotify
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # Nanocurrency
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/nanocurrency`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'nanocurrency'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install nanocurrency
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/nanocurrency. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
+
41
+ ## Code of Conduct
42
+
43
+ Everyone interacting in the Nanocurrency project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/nanocurrency/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+ require "rake/extensiontask"
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task :default => :spec
8
+
9
+ spec = Gem::Specification.load('nanocurrency.gemspec')
10
+
11
+ Rake::ExtensionTask.new('nanocurrency_ext', spec) do |ext|
12
+ ext.source_pattern = '*{c,h}'
13
+ end
14
+
15
+ desc 'clean, compile, and run the full test suite'
16
+ task full: %w(clean compile spec)
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "nanocurrency"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/ext/.DS_Store ADDED
Binary file
@@ -0,0 +1,72 @@
1
+ /*
2
+ BLAKE2 reference source code package - optimized C implementations
3
+
4
+ Copyright 2012, Samuel Neves <sneves@dei.uc.pt>. You may use this under the
5
+ terms of the CC0, the OpenSSL Licence, or the Apache Public License 2.0, at
6
+ your option. The terms of these licenses can be found at:
7
+
8
+ - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
9
+ - OpenSSL license : https://www.openssl.org/source/license.html
10
+ - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ More information about the BLAKE2 hash function can be found at
13
+ https://blake2.net.
14
+ */
15
+ #ifndef BLAKE2_CONFIG_H
16
+ #define BLAKE2_CONFIG_H
17
+
18
+ /* These don't work everywhere */
19
+ #if defined(__SSE2__) || defined(__x86_64__) || defined(__amd64__)
20
+ #define HAVE_SSE2
21
+ #endif
22
+
23
+ #if defined(__SSSE3__)
24
+ #define HAVE_SSSE3
25
+ #endif
26
+
27
+ #if defined(__SSE4_1__)
28
+ #define HAVE_SSE41
29
+ #endif
30
+
31
+ #if defined(__AVX__)
32
+ #define HAVE_AVX
33
+ #endif
34
+
35
+ #if defined(__XOP__)
36
+ #define HAVE_XOP
37
+ #endif
38
+
39
+
40
+ #ifdef HAVE_AVX2
41
+ #ifndef HAVE_AVX
42
+ #define HAVE_AVX
43
+ #endif
44
+ #endif
45
+
46
+ #ifdef HAVE_XOP
47
+ #ifndef HAVE_AVX
48
+ #define HAVE_AVX
49
+ #endif
50
+ #endif
51
+
52
+ #ifdef HAVE_AVX
53
+ #ifndef HAVE_SSE41
54
+ #define HAVE_SSE41
55
+ #endif
56
+ #endif
57
+
58
+ #ifdef HAVE_SSE41
59
+ #ifndef HAVE_SSSE3
60
+ #define HAVE_SSSE3
61
+ #endif
62
+ #endif
63
+
64
+ #ifdef HAVE_SSSE3
65
+ #define HAVE_SSE2
66
+ #endif
67
+
68
+ #if !defined(HAVE_SSE2)
69
+ #error "This code requires at least SSE2."
70
+ #endif
71
+
72
+ #endif
@@ -0,0 +1,160 @@
1
+ /*
2
+ BLAKE2 reference source code package - reference C implementations
3
+
4
+ Copyright 2012, Samuel Neves <sneves@dei.uc.pt>. You may use this under the
5
+ terms of the CC0, the OpenSSL Licence, or the Apache Public License 2.0, at
6
+ your option. The terms of these licenses can be found at:
7
+
8
+ - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
9
+ - OpenSSL license : https://www.openssl.org/source/license.html
10
+ - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ More information about the BLAKE2 hash function can be found at
13
+ https://blake2.net.
14
+ */
15
+ #ifndef BLAKE2_IMPL_H
16
+ #define BLAKE2_IMPL_H
17
+
18
+ #include <stdint.h>
19
+ #include <string.h>
20
+
21
+ #if !defined(__cplusplus) && (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L)
22
+ #if defined(_MSC_VER)
23
+ #define BLAKE2_INLINE __inline
24
+ #elif defined(__GNUC__)
25
+ #define BLAKE2_INLINE __inline__
26
+ #else
27
+ #define BLAKE2_INLINE
28
+ #endif
29
+ #else
30
+ #define BLAKE2_INLINE inline
31
+ #endif
32
+
33
+ static BLAKE2_INLINE uint32_t load32( const void *src )
34
+ {
35
+ #if defined(NATIVE_LITTLE_ENDIAN)
36
+ uint32_t w;
37
+ memcpy(&w, src, sizeof w);
38
+ return w;
39
+ #else
40
+ const uint8_t *p = ( const uint8_t * )src;
41
+ return (( uint32_t )( p[0] ) << 0) |
42
+ (( uint32_t )( p[1] ) << 8) |
43
+ (( uint32_t )( p[2] ) << 16) |
44
+ (( uint32_t )( p[3] ) << 24) ;
45
+ #endif
46
+ }
47
+
48
+ static BLAKE2_INLINE uint64_t load64( const void *src )
49
+ {
50
+ #if defined(NATIVE_LITTLE_ENDIAN)
51
+ uint64_t w;
52
+ memcpy(&w, src, sizeof w);
53
+ return w;
54
+ #else
55
+ const uint8_t *p = ( const uint8_t * )src;
56
+ return (( uint64_t )( p[0] ) << 0) |
57
+ (( uint64_t )( p[1] ) << 8) |
58
+ (( uint64_t )( p[2] ) << 16) |
59
+ (( uint64_t )( p[3] ) << 24) |
60
+ (( uint64_t )( p[4] ) << 32) |
61
+ (( uint64_t )( p[5] ) << 40) |
62
+ (( uint64_t )( p[6] ) << 48) |
63
+ (( uint64_t )( p[7] ) << 56) ;
64
+ #endif
65
+ }
66
+
67
+ static BLAKE2_INLINE uint16_t load16( const void *src )
68
+ {
69
+ #if defined(NATIVE_LITTLE_ENDIAN)
70
+ uint16_t w;
71
+ memcpy(&w, src, sizeof w);
72
+ return w;
73
+ #else
74
+ const uint8_t *p = ( const uint8_t * )src;
75
+ return (( uint16_t )( p[0] ) << 0) |
76
+ (( uint16_t )( p[1] ) << 8) ;
77
+ #endif
78
+ }
79
+
80
+ static BLAKE2_INLINE void store16( void *dst, uint16_t w )
81
+ {
82
+ #if defined(NATIVE_LITTLE_ENDIAN)
83
+ memcpy(dst, &w, sizeof w);
84
+ #else
85
+ uint8_t *p = ( uint8_t * )dst;
86
+ *p++ = ( uint8_t )w; w >>= 8;
87
+ *p++ = ( uint8_t )w;
88
+ #endif
89
+ }
90
+
91
+ static BLAKE2_INLINE void store32( void *dst, uint32_t w )
92
+ {
93
+ #if defined(NATIVE_LITTLE_ENDIAN)
94
+ memcpy(dst, &w, sizeof w);
95
+ #else
96
+ uint8_t *p = ( uint8_t * )dst;
97
+ p[0] = (uint8_t)(w >> 0);
98
+ p[1] = (uint8_t)(w >> 8);
99
+ p[2] = (uint8_t)(w >> 16);
100
+ p[3] = (uint8_t)(w >> 24);
101
+ #endif
102
+ }
103
+
104
+ static BLAKE2_INLINE void store64( void *dst, uint64_t w )
105
+ {
106
+ #if defined(NATIVE_LITTLE_ENDIAN)
107
+ memcpy(dst, &w, sizeof w);
108
+ #else
109
+ uint8_t *p = ( uint8_t * )dst;
110
+ p[0] = (uint8_t)(w >> 0);
111
+ p[1] = (uint8_t)(w >> 8);
112
+ p[2] = (uint8_t)(w >> 16);
113
+ p[3] = (uint8_t)(w >> 24);
114
+ p[4] = (uint8_t)(w >> 32);
115
+ p[5] = (uint8_t)(w >> 40);
116
+ p[6] = (uint8_t)(w >> 48);
117
+ p[7] = (uint8_t)(w >> 56);
118
+ #endif
119
+ }
120
+
121
+ static BLAKE2_INLINE uint64_t load48( const void *src )
122
+ {
123
+ const uint8_t *p = ( const uint8_t * )src;
124
+ return (( uint64_t )( p[0] ) << 0) |
125
+ (( uint64_t )( p[1] ) << 8) |
126
+ (( uint64_t )( p[2] ) << 16) |
127
+ (( uint64_t )( p[3] ) << 24) |
128
+ (( uint64_t )( p[4] ) << 32) |
129
+ (( uint64_t )( p[5] ) << 40) ;
130
+ }
131
+
132
+ static BLAKE2_INLINE void store48( void *dst, uint64_t w )
133
+ {
134
+ uint8_t *p = ( uint8_t * )dst;
135
+ p[0] = (uint8_t)(w >> 0);
136
+ p[1] = (uint8_t)(w >> 8);
137
+ p[2] = (uint8_t)(w >> 16);
138
+ p[3] = (uint8_t)(w >> 24);
139
+ p[4] = (uint8_t)(w >> 32);
140
+ p[5] = (uint8_t)(w >> 40);
141
+ }
142
+
143
+ static BLAKE2_INLINE uint32_t rotr32( const uint32_t w, const unsigned c )
144
+ {
145
+ return ( w >> c ) | ( w << ( 32 - c ) );
146
+ }
147
+
148
+ static BLAKE2_INLINE uint64_t rotr64( const uint64_t w, const unsigned c )
149
+ {
150
+ return ( w >> c ) | ( w << ( 64 - c ) );
151
+ }
152
+
153
+ /* prevents compiler optimizing out memset() */
154
+ static BLAKE2_INLINE void secure_zero_memory(void *v, size_t n)
155
+ {
156
+ static void *(*const volatile memset_v)(void *, int, size_t) = &memset;
157
+ memset_v(v, 0, n);
158
+ }
159
+
160
+ #endif