Welcome to the CHICKEN Scheme pasting service

chicken-tweetnacl and tweetnacl.js pasted by klm` on Fri Jan 29 13:04:20 2016

(use tweetnacl base64)

(define sk
  (string->blob
   (base64-decode (string-append "49sFCt7Gh8gcbeE+ah/ojWAQiYaafiV8iX6m2Wdn3EYCTckgw"
                                 "0JZGEITrzr34HEQXQhPDKdkOtlW68xLgGzFZw=="))))

(define pk (string->blob (base64-decode "Ak3JIMNCWRhCE6869+BxEF0ITwynZDrZVuvMS4BsxWc=")))


;; verifying empty string from tweetnacl js works:
((asymmetric-verify pk)
 (base64-decode "4SmIdjvxlarfcIZmw2NRow42RwEVuBztLSHp2cqr10hHpq0vRU2sf7DGOM9EAenq+IyycNMYOD1di6zF6fQFCQ=="))

;; sign "hello" from https://dchest.github.io/tweetnacl-js/#/sign with the secret key:
;; "49sFCt7Gh8gcbeE+ah/ojWAQiYaafiV8iX6m2Wdn3EYCTckgw0JZGEITrzr34HEQXQhPDKdkOtlW68xLgGzFZw=="
;; but this doesn't work with chicken-tweetnacl
((asymmetric-verify pk)
 (base64-decode "ccCcxjh+xxdUf/qozU7Nsr/InOK3yFEiuJmTQUhCF8kqVuFKO/WGXLf5nj2QPsSHM+9at6s56Ox/GhIN4vtYDQ=="))

;; chicken-tweetnacl produces a different signature for the same content:
;; "ccCcxjh+xxdUf/qozU7Nsr/InOK3yFEiuJmTQUhCF8kqVuFKO/WGXLf5nj2QPsSHM+9at6s56Ox/GhIN4vtYDWhlbGxv"
(base64-encode ((asymmetric-sign sk) "hello"))

;; verifying this, things work.
((asymmetric-verify pk)
 (base64-decode "ccCcxjh+xxdUf/qozU7Nsr/InOK3yFEiuJmTQUhCF8kqVuFKO/WGXLf5nj2QPsSHM+9at6s56Ox/GhIN4vtYDWhlbGxv"))

;; possible causes:
;; tweetnacl.js and the original tweetnacl.impl.c are different somehow
;; https://dchest.github.io/tweetnacl-js/#/sign does some strange UTF16 encoding? <-- nope, it's UFT8

it actually works! added by klm` on Fri Jan 29 17:56:29 2016


sign-asymmetric outputs both the signature and the message content. the tweetnacl just outputs the signature (typically named `detached`).

if you substring out just the signature, it works:

(define ((asymmetric-sign-detached sk) m)
  (substring ((asymmetric-sign sk) m)
             0 asymmetric-sign-secretkeybytes))

Your annotation:

Enter a new annotation:

Your nick:
The title of your paste:
Your paste (mandatory) :
What type of object does `for-each' expect as second argument?
Visually impaired? Let me spell it for you (wav file) download WAV