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

Larger coverage of hashes #1

Open
DonaldTsang opened this issue Oct 28, 2018 · 6 comments
Open

Larger coverage of hashes #1

DonaldTsang opened this issue Oct 28, 2018 · 6 comments

Comments

@DonaldTsang
Copy link

224 256 384 512
BMW - [ ] - [ ] Faster than MD5 - [ ] - [ ] Faster than SHA1
ECHO - [ ] - [ ] Faster than SHA1 - [ ] - [ ] Slower than SHA256
ECHO single pipe - [ ] - [ ] Faster than SHA1 - [ ] - [ ] Faster than SHA256
BLAKE2 - [ ] (2s/224) - [ ] Faster than MD5 (BLAKE2s) - [ ] (2b/384) - [ ] Faster than SHA1 (BLAKE2b)
SHAVite3 - [ ] - [ ] Faster than MD5 - [ ] - [ ] Faster than SHA1
CubeHash - [ ] (8/32) - [ ] (8/32 but for 256-bit) - [ ] (8/32) - [ ] Faster than MD5 (CubeHash8/32)
SHABAL - [ ] - [ ] Faster than SHA256 - [ ] - [ ] Faster than SHA512
Skien512 - [ ] - [ ] Faster than SHA256 - [ ] - [ ] Faster than SHA256
BLAKE - [ ] - [ ] Faster than SHA256 - [ ] - [ ] Faster than SHA256
BBLAKE - [ ] - [ ] Faster than SHA256 - [ ] - [ ] Slower than SHA256
SKEIN1024 - [ ] (384~448bit) - [ ] Slower than SHA256 (512bit) - [ ] (768bit) - [ ] Faster than SHA256 (1024bit)
SHA3 - [ ] - [ ] Faster than SHA256 - [ ] - [ ] Slower than SHA256
Keccak Treed2 - [ ] - [ ] Faster than MD5 - [ ] - [ ] Faster than SHA256
SHA2 - [ ] - [ ] - [ ] - [ ]
@zebra-lucky
Copy link
Owner

Yep, this code is very draft and ported from JS version. Need to refactor and speedup.

@DonaldTsang
Copy link
Author

DonaldTsang commented Oct 29, 2018

@zebra-lucky Cubehash and keccak should be easy
Here are the notes I made for Cubehash

def s(x):
  for i in range(16): x[16+i]=(x[16+i]+x[i])%(1<<32) # step 1
  for i in range(16): x[i]=((x[i]<<7)+(x[i]>>25))%(1<<32)# step 2
  for i in range(8): x[i],x[8+i]=x[8+i],x[i] # step 3
  for i in range(16): x[i]^=x[16+i] # step 4
  for i,j in range(0,16,4), [0,1]: x[16+i+j],x[18+i+j]=x[18+i+j],x[16+i+j] # step 5
  for i in range(16): x[16+i]=(x[16+i]+x[i])%(1<<32) # step 6
  for i in range(16): ((x[i]<<11)+(x[i]>>21))%(1<<32)# step 7
  for i,j in [0,8], range(4): x[i+j],x[4+i+j]=x[4+i+j],x[i+j] # step 8
  for i in range(16): x[i]^=x[16+i] # step 9
  for i in range(0,16,2): x[i],x[16+i]=x[16+i],x[i] # step 10
  return x

def cubehash(msg,i,r,b,f,h):
  assert isinstance(msg,bytes)
  ctx=[h/8,b,r]+[0 for _ in range(29)]
  for _ in range(i): ctx = s(ctx) # initialization
  msg=[msg[n:n+b] for n in range(0,len(msg),b)]
  msg[-1] += (b'\x80'+b'\x00'*(b-len(msg[-1])-1)) if len(msg[-1])!=b else b''
  for m in msg:
     int.from_bytes(???, byteorder='big') # convert and then XOR into ctx
     for _ in range(r): ctx = s(ctx)
  ctx[31]^=1
  for _ in range(f): ctx = s(ctx)
  # return the first h/8 bytes of the ctx

@zebra-lucky
Copy link
Owner

zebra-lucky commented Oct 31, 2018

Thank you for comments!

Sorry, at the moment I have no time to continue enhance code of this repo.
This was a dirty try to port JS version without redoing code structure.
There was a think to limit expectation of length of input data to all hashes
to prev output lenght, and refactor all code structure, but no time left currently.

@DonaldTsang
Copy link
Author

@zebra-lucky Does it get the same hash with the reference implementations in C? Just wondering.

@DonaldTsang
Copy link
Author

Cubehash and keccak should be easy
Here are the notes I made for Cubehash

def s(x):
  for i in range(16): x[16+i]=(x[16+i]+x[i])%(1<<32) # step 1
  for i in range(16): x[i]=((x[i]<<7)+(x[i]>>25))%(1<<32)# step 2
  for i in range(8): x[i],x[8+i]=x[8+i],x[i] # step 3
  for i in range(16): x[i]^=x[16+i] # step 4
  for i,j in range(0,16,4), [0,1]: x[16+i+j],x[18+i+j]=x[18+i+j],x[16+i+j] # step 5
  for i in range(16): x[16+i]=(x[16+i]+x[i])%(1<<32) # step 6
  for i in range(16): ((x[i]<<11)+(x[i]>>21))%(1<<32)# step 7
  for i,j in [0,8], range(4): x[i+j],x[4+i+j]=x[4+i+j],x[i+j] # step 8
  for i in range(16): x[i]^=x[16+i] # step 9
  for i in range(0,16,2): x[i],x[16+i]=x[16+i],x[i] # step 10
  return x

def cubehash(msg,i,r,b,f,h):
  assert isinstance(msg,bytes)
  ctx=[h/8,b,r]+[0 for _ in range(29)]
  for _ in range(i): ctx = s(ctx) # initialization
  msg=[msg[n:n+b] for n in range(0,len(msg),b)]
  msg[-1] += (b'\x80'+b'\x00'*(b-len(msg[-1])-1)) if len(msg[-1])!=b else b''
  for m in msg:
     int.from_bytes(???, byteorder='big') # convert and then XOR into ctx
     for _ in range(r): ctx = s(ctx)
  ctx[31]^=1
  for _ in range(f): ctx = s(ctx)
  # return the first h/8 bytes of the ctx

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

No branches or pull requests

2 participants