· 7 years ago · Sep 27, 2018, 11:12 AM
1# Libsodium.js wrapper - API usage
2
3Once you've included libsodium.js and libsodium-wrapper.js, all the available wrapped functions and constants can be accessed in the `sodium` object.
4
5To learn about the role of each method, please refer to the original [documentation](http://doc.libsodium.org) of libsodium
6
7List of existing types:
8* `Buf`: An Uint8Array of a determined size. Used for keys, nonces, etc...
9* `Unsized Buf`: An Uint8Array of an arbitrary size. Used for messages to sign, encrypt, hash, etc...
10* `Optional unsized buf`
11* `Unsigned Integer`
12* `Generichash state`
13* `OneTimeAuth state`
14* `Secretstream XChaCha20Poly1305 state`
15* `Signature state`
16* `Randombytes implementation`
17* `String`
18* outputFormat: A string indicating in which output format you want the result to be returned. Supported values are "uint8array", "text", "hex", "base64". Optional parameter. Not available on all functions. Defaults to uint8array.
19
20Please note that a function that returns more than one variable will in fact return an object, which will contain the outputs in question and whose attributes will be named after the outputs' names
21
22Please also note that these are the function available "in general" in the wrapper. The actual number of available functions in given build may be inferior to that, depending on what functions you choose to build to JS.
23
24In addition to the main functions listed below, the library comes with a short list of helper methods. And here they are:
25* `from_string(string)`: converts a standard string into a Uint8Array
26* `to_string(buf)`: converts a Uint8Array to a standard string
27* `to_hex(buf)`: returns the hexadecimal representation of the provided buf
28* `from_hex(string)`: converts the provided hex-string into a Uint8Array and returns it
29* `to_base64(buf, variant)`: returns the base64 representation of the provided buf
30* `from_base64(string, variant)`: tries to convert the supposedly base64 string into a Uint8Array
31* `symbols()`: returns a list of the currently methods and constants
32* `raw`: attribute referencing the raw emscripten-built libsodium library that we are wrapping
33
34## crypto_aead_chacha20poly1305_decrypt
35Function
36
37__Parameters:__
38* `secret_nonce`: Optional unsized buf
39* `ciphertext`: Minsized buf
40* `additional_data`: Optional unsized buf
41* `public_nonce`: Buf (size: libsodium._crypto_aead_chacha20poly1305_npubbytes())
42* `key`: Buf (size: libsodium._crypto_aead_chacha20poly1305_keybytes())
43
44__Outputs:__
45* `message`: Buf (size: ciphertext_length - libsodium._crypto_aead_chacha20poly1305_abytes())
46
47
48## crypto_aead_chacha20poly1305_decrypt_detached
49Function
50
51__Parameters:__
52* `secret_nonce`: Optional unsized buf
53* `ciphertext`: Unsized buf
54* `mac`: Buf (size: libsodium._crypto_box_macbytes())
55* `additional_data`: Optional unsized buf
56* `public_nonce`: Buf (size: libsodium._crypto_aead_chacha20poly1305_npubbytes())
57* `key`: Buf (size: libsodium._crypto_aead_chacha20poly1305_keybytes())
58
59__Outputs:__
60* `message`: Buf (size: ciphertext_length)
61
62
63## crypto_aead_chacha20poly1305_encrypt
64Function
65
66__Parameters:__
67* `message`: Unsized buf
68* `additional_data`: Optional unsized buf
69* `secret_nonce`: Optional unsized buf
70* `public_nonce`: Buf (size: libsodium._crypto_aead_chacha20poly1305_npubbytes())
71* `key`: Buf (size: libsodium._crypto_aead_chacha20poly1305_keybytes())
72
73__Outputs:__
74* `ciphertext`: Buf (size: message_length + libsodium._crypto_aead_chacha20poly1305_abytes())
75
76
77## crypto_aead_chacha20poly1305_encrypt_detached
78Function
79
80__Parameters:__
81* `message`: Unsized buf
82* `additional_data`: Optional unsized buf
83* `secret_nonce`: Optional unsized buf
84* `public_nonce`: Buf (size: libsodium._crypto_aead_chacha20poly1305_npubbytes())
85* `key`: Buf (size: libsodium._crypto_aead_chacha20poly1305_keybytes())
86
87__Outputs:__
88* `ciphertext`: Buf (size: message_length)
89* `mac`: Buf (size: libsodium._crypto_aead_chacha20poly1305_abytes())
90
91
92## crypto_aead_chacha20poly1305_ietf_decrypt
93Function
94
95__Parameters:__
96* `secret_nonce`: Optional unsized buf
97* `ciphertext`: Minsized buf
98* `additional_data`: Optional unsized buf
99* `public_nonce`: Buf (size: libsodium._crypto_aead_chacha20poly1305_ietf_npubbytes())
100* `key`: Buf (size: libsodium._crypto_aead_chacha20poly1305_ietf_keybytes())
101
102__Outputs:__
103* `message`: Buf (size: ciphertext_length - libsodium._crypto_aead_chacha20poly1305_ietf_abytes())
104
105
106## crypto_aead_chacha20poly1305_ietf_decrypt_detached
107Function
108
109__Parameters:__
110* `secret_nonce`: Optional unsized buf
111* `ciphertext`: Unsized buf
112* `mac`: Buf (size: libsodium._crypto_box_macbytes())
113* `additional_data`: Optional unsized buf
114* `public_nonce`: Buf (size: libsodium._crypto_aead_chacha20poly1305_ietf_npubbytes())
115* `key`: Buf (size: libsodium._crypto_aead_chacha20poly1305_ietf_keybytes())
116
117__Outputs:__
118* `message`: Buf (size: ciphertext_length)
119
120
121## crypto_aead_chacha20poly1305_ietf_encrypt
122Function
123
124__Parameters:__
125* `message`: Unsized buf
126* `additional_data`: Optional unsized buf
127* `secret_nonce`: Optional unsized buf
128* `public_nonce`: Buf (size: libsodium._crypto_aead_chacha20poly1305_ietf_npubbytes())
129* `key`: Buf (size: libsodium._crypto_aead_chacha20poly1305_ietf_keybytes())
130
131__Outputs:__
132* `ciphertext`: Buf (size: message_length + libsodium._crypto_aead_chacha20poly1305_ietf_abytes())
133
134
135## crypto_aead_chacha20poly1305_ietf_encrypt_detached
136Function
137
138__Parameters:__
139* `message`: Unsized buf
140* `additional_data`: Optional unsized buf
141* `secret_nonce`: Optional unsized buf
142* `public_nonce`: Buf (size: libsodium._crypto_aead_chacha20poly1305_ietf_npubbytes())
143* `key`: Buf (size: libsodium._crypto_aead_chacha20poly1305_ietf_keybytes())
144
145__Outputs:__
146* `ciphertext`: Buf (size: message_length)
147* `mac`: Buf (size: libsodium._crypto_aead_chacha20poly1305_ietf_abytes())
148
149
150## crypto_aead_chacha20poly1305_ietf_keygen
151Function
152
153__Parameters:__
154
155__Outputs:__
156* `output`: Buf (size: libsodium._crypto_aead_chacha20poly1305_ietf_keybytes())
157
158
159## crypto_aead_chacha20poly1305_keygen
160Function
161
162__Parameters:__
163
164__Outputs:__
165* `output`: Buf (size: libsodium._crypto_aead_chacha20poly1305_keybytes())
166
167
168## crypto_aead_xchacha20poly1305_ietf_decrypt
169Function
170
171__Parameters:__
172* `secret_nonce`: Optional unsized buf
173* `ciphertext`: Minsized buf
174* `additional_data`: Optional unsized buf
175* `public_nonce`: Buf (size: libsodium._crypto_aead_xchacha20poly1305_ietf_npubbytes())
176* `key`: Buf (size: libsodium._crypto_aead_xchacha20poly1305_ietf_keybytes())
177
178__Outputs:__
179* `message`: Buf (size: ciphertext_length - libsodium._crypto_aead_xchacha20poly1305_ietf_abytes())
180
181
182## crypto_aead_xchacha20poly1305_ietf_decrypt_detached
183Function
184
185__Parameters:__
186* `secret_nonce`: Optional unsized buf
187* `ciphertext`: Unsized buf
188* `mac`: Buf (size: libsodium._crypto_box_macbytes())
189* `additional_data`: Optional unsized buf
190* `public_nonce`: Buf (size: libsodium._crypto_aead_xchacha20poly1305_ietf_npubbytes())
191* `key`: Buf (size: libsodium._crypto_aead_xchacha20poly1305_ietf_keybytes())
192
193__Outputs:__
194* `message`: Buf (size: ciphertext_length)
195
196
197## crypto_aead_xchacha20poly1305_ietf_encrypt
198Function
199
200__Parameters:__
201* `message`: Unsized buf
202* `additional_data`: Optional unsized buf
203* `secret_nonce`: Optional unsized buf
204* `public_nonce`: Buf (size: libsodium._crypto_aead_xchacha20poly1305_ietf_npubbytes())
205* `key`: Buf (size: libsodium._crypto_aead_xchacha20poly1305_ietf_keybytes())
206
207__Outputs:__
208* `ciphertext`: Buf (size: message_length + libsodium._crypto_aead_xchacha20poly1305_ietf_abytes())
209
210
211## crypto_aead_xchacha20poly1305_ietf_encrypt_detached
212Function
213
214__Parameters:__
215* `message`: Unsized buf
216* `additional_data`: Optional unsized buf
217* `secret_nonce`: Optional unsized buf
218* `public_nonce`: Buf (size: libsodium._crypto_aead_xchacha20poly1305_ietf_npubbytes())
219* `key`: Buf (size: libsodium._crypto_aead_xchacha20poly1305_ietf_keybytes())
220
221__Outputs:__
222* `ciphertext`: Buf (size: message_length)
223* `mac`: Buf (size: libsodium._crypto_aead_xchacha20poly1305_ietf_abytes())
224
225
226## crypto_aead_xchacha20poly1305_ietf_keygen
227Function
228
229__Parameters:__
230
231__Outputs:__
232* `output`: Buf (size: libsodium._crypto_aead_xchacha20poly1305_ietf_keybytes())
233
234
235## crypto_auth
236Function
237
238__Parameters:__
239* `message`: Unsized buf
240* `key`: Buf (size: libsodium._crypto_auth_keybytes())
241
242__Outputs:__
243* `tag`: Buf (size: libsodium._crypto_auth_bytes())
244
245
246## crypto_auth_hmacsha256
247Function
248
249__Parameters:__
250* `message`: Unsized buf
251* `key`: Buf (size: libsodium._crypto_auth_hmacsha256_keybytes())
252
253__Outputs:__
254* `hash`: Buf (size: libsodium._crypto_auth_hmacsha256_bytes())
255
256
257## crypto_auth_hmacsha256_keygen
258Function
259
260__Parameters:__
261
262__Outputs:__
263* `output`: Buf (size: libsodium._crypto_auth_hmacsha256_keybytes())
264
265
266## crypto_auth_hmacsha256_verify
267Function
268
269__Parameters:__
270* `tag`: Buf (size: libsodium._crypto_auth_hmacsha256_bytes())
271* `message`: Unsized buf
272* `key`: Buf (size: libsodium._crypto_auth_hmacsha256_keybytes())
273
274__Outputs:__
275Boolean. True if method executed with success; false otherwise
276
277
278## crypto_auth_hmacsha512
279Function
280
281__Parameters:__
282* `message`: Unsized buf
283* `key`: Buf (size: libsodium._crypto_auth_hmacsha512_keybytes())
284
285__Outputs:__
286* `hash`: Buf (size: libsodium._crypto_auth_hmacsha512_bytes())
287
288
289## crypto_auth_hmacsha512_keygen
290Function
291
292__Parameters:__
293
294__Outputs:__
295* `output`: Buf (size: libsodium._crypto_auth_hmacsha512_keybytes())
296
297
298## crypto_auth_hmacsha512_verify
299Function
300
301__Parameters:__
302* `tag`: Buf (size: libsodium._crypto_auth_hmacsha512_bytes())
303* `message`: Unsized buf
304* `key`: Buf (size: libsodium._crypto_auth_hmacsha512_keybytes())
305
306__Outputs:__
307Boolean. True if method executed with success; false otherwise
308
309
310## crypto_auth_keygen
311Function
312
313__Parameters:__
314
315__Outputs:__
316* `output`: Buf (size: libsodium._crypto_auth_keybytes())
317
318
319## crypto_auth_verify
320Function
321
322__Parameters:__
323* `tag`: Buf (size: libsodium._crypto_auth_bytes())
324* `message`: Unsized buf
325* `key`: Buf (size: libsodium._crypto_auth_keybytes())
326
327__Outputs:__
328Boolean. True if method executed with success; false otherwise
329
330
331## crypto_box_beforenm
332Function
333
334__Parameters:__
335* `publicKey`: Buf (size: libsodium._crypto_box_publickeybytes())
336* `privateKey`: Buf (size: libsodium._crypto_box_secretkeybytes())
337
338__Outputs:__
339* `sharedKey`: Buf (size: libsodium._crypto_box_beforenmbytes())
340
341
342## crypto_box_curve25519xchacha20poly1305_keypair
343Function
344
345__Parameters:__
346
347__Outputs:__
348* `publicKey`: Buf (size: libsodium._crypto_box_curve25519xchacha20poly1305_publickeybytes())
349* `secretKey`: Buf (size: libsodium._crypto_box_curve25519xchacha20poly1305_secretkeybytes())
350
351
352## crypto_box_curve25519xchacha20poly1305_seal
353Function
354
355__Parameters:__
356* `message`: Unsized buf
357* `publicKey`: Buf (size: libsodium._crypto_box_curve25519xchacha20poly1305_publickeybytes())
358
359__Outputs:__
360* `ciphertext`: Buf (size: message_length + libsodium._crypto_box_curve25519xchacha20poly1305_sealbytes())
361
362
363## crypto_box_curve25519xchacha20poly1305_seal_open
364Function
365
366__Parameters:__
367* `ciphertext`: Minsized buf
368* `publicKey`: Buf (size: libsodium._crypto_box_curve25519xchacha20poly1305_publickeybytes())
369* `secretKey`: Buf (size: libsodium._crypto_box_curve25519xchacha20poly1305_secretkeybytes())
370
371__Outputs:__
372* `plaintext`: Buf (size: ciphertext_length - libsodium._crypto_box_curve25519xchacha20poly1305_sealbytes())
373
374
375## crypto_box_detached
376Function
377
378__Parameters:__
379* `message`: Unsized buf
380* `nonce`: Buf (size: libsodium._crypto_box_noncebytes())
381* `publicKey`: Buf (size: libsodium._crypto_box_publickeybytes())
382* `privateKey`: Buf (size: libsodium._crypto_box_secretkeybytes())
383
384__Outputs:__
385* `ciphertext`: Buf (size: message_length)
386* `mac`: Buf (size: libsodium._crypto_box_macbytes())
387
388
389## crypto_box_easy
390Function
391
392__Parameters:__
393* `message`: Unsized buf
394* `nonce`: Buf (size: libsodium._crypto_box_noncebytes())
395* `publicKey`: Buf (size: libsodium._crypto_box_publickeybytes())
396* `privateKey`: Buf (size: libsodium._crypto_box_secretkeybytes())
397
398__Outputs:__
399* `ciphertext`: Buf (size: message_length + libsodium._crypto_box_macbytes())
400
401
402## crypto_box_easy_afternm
403Function
404
405__Parameters:__
406* `message`: Unsized buf
407* `nonce`: Buf (size: libsodium._crypto_box_noncebytes())
408* `sharedKey`: Buf (size: libsodium._crypto_box_beforenmbytes())
409
410__Outputs:__
411* `ciphertext`: Buf (size: message_length + libsodium._crypto_box_macbytes())
412
413
414## crypto_box_keypair
415Function
416
417__Parameters:__
418
419__Outputs:__
420* `publicKey`: Buf (size: libsodium._crypto_box_publickeybytes())
421* `privateKey`: Buf (size: libsodium._crypto_box_secretkeybytes())
422
423
424## crypto_box_open_detached
425Function
426
427__Parameters:__
428* `ciphertext`: Unsized buf
429* `mac`: Buf (size: libsodium._crypto_box_macbytes())
430* `nonce`: Buf (size: libsodium._crypto_box_noncebytes())
431* `publicKey`: Buf (size: libsodium._crypto_box_publickeybytes())
432* `privateKey`: Buf (size: libsodium._crypto_box_secretkeybytes())
433
434__Outputs:__
435* `plaintext`: Buf (size: ciphertext_length)
436
437
438## crypto_box_open_easy
439Function
440
441__Parameters:__
442* `ciphertext`: Minsized buf
443* `nonce`: Buf (size: libsodium._crypto_box_noncebytes())
444* `publicKey`: Buf (size: libsodium._crypto_box_publickeybytes())
445* `privateKey`: Buf (size: libsodium._crypto_box_secretkeybytes())
446
447__Outputs:__
448* `plaintext`: Buf (size: ciphertext_length - libsodium._crypto_box_macbytes())
449
450
451## crypto_box_open_easy_afternm
452Function
453
454__Parameters:__
455* `ciphertext`: Unsized buf
456* `nonce`: Buf (size: libsodium._crypto_box_noncebytes())
457* `sharedKey`: Buf (size: libsodium._crypto_box_beforenmbytes())
458
459__Outputs:__
460* `plaintext`: Buf (size: ciphertext_length - libsodium._crypto_box_macbytes())
461
462
463## crypto_box_seal
464Function
465
466__Parameters:__
467* `message`: Unsized buf
468* `publicKey`: Buf (size: libsodium._crypto_box_publickeybytes())
469
470__Outputs:__
471* `ciphertext`: Buf (size: message_length + libsodium._crypto_box_sealbytes())
472
473
474## crypto_box_seal_open
475Function
476
477__Parameters:__
478* `ciphertext`: Minsized buf
479* `publicKey`: Buf (size: libsodium._crypto_box_publickeybytes())
480* `privateKey`: Buf (size: libsodium._crypto_box_secretkeybytes())
481
482__Outputs:__
483* `plaintext`: Buf (size: ciphertext_length - libsodium._crypto_box_sealbytes())
484
485
486## crypto_box_seed_keypair
487Function
488
489__Parameters:__
490* `seed`: Buf (size: libsodium._crypto_box_seedbytes())
491
492__Outputs:__
493* `publicKey`: Buf (size: libsodium._crypto_box_publickeybytes())
494* `privateKey`: Buf (size: libsodium._crypto_box_secretkeybytes())
495
496
497## crypto_generichash
498Function
499
500__Parameters:__
501* `hash_length`: Unsigned Integer
502* `message`: Unsized buf
503* `key`: Optional unsized buf
504
505__Outputs:__
506* `hash`: Buf (size: hash_length)
507
508
509## crypto_generichash_final
510Function
511
512__Parameters:__
513* `state_address`: Generichash state address
514* `hash_length`: Unsigned Integer
515
516__Outputs:__
517* `hash`: Buf (size: hash_length)
518
519
520## crypto_generichash_init
521Function
522
523__Parameters:__
524* `key`: Optional unsized buf
525* `hash_length`: Unsigned Integer
526
527__Outputs:__
528* `state`: Generichash state
529
530
531## crypto_generichash_keygen
532Function
533
534__Parameters:__
535
536__Outputs:__
537* `output`: Buf (size: libsodium._crypto_generichash_keybytes())
538
539
540## crypto_generichash_update
541Function
542
543__Parameters:__
544* `state_address`: Generichash state address
545* `message_chunk`: Unsized buf
546
547__Outputs:__
548Boolean. True if method executed with success; false otherwise
549
550
551## crypto_hash
552Function
553
554__Parameters:__
555* `message`: Unsized buf
556
557__Outputs:__
558* `hash`: Buf (size: libsodium._crypto_hash_bytes())
559
560
561## crypto_hash_sha256
562Function
563
564__Parameters:__
565* `message`: Unsized buf
566
567__Outputs:__
568* `hash`: Buf (size: libsodium._crypto_hash_sha256_bytes())
569
570
571## crypto_hash_sha512
572Function
573
574__Parameters:__
575* `message`: Unsized buf
576
577__Outputs:__
578* `hash`: Buf (size: libsodium._crypto_hash_sha512_bytes())
579
580
581## crypto_kdf_derive_from_key
582Function
583
584__Parameters:__
585* `subkey_len`: Unsigned Integer
586* `subkey_id`: Unsigned Integer
587* `ctx`: A string
588* `key`: Buf (size: libsodium._crypto_kdf_keybytes())
589
590__Outputs:__
591* `subkey`: Buf (size: subkey_len)
592
593
594## crypto_kdf_keygen
595Function
596
597__Parameters:__
598
599__Outputs:__
600* `output`: Buf (size: libsodium._crypto_kdf_keybytes())
601
602
603## crypto_kx_client_session_keys
604Function
605
606__Parameters:__
607* `clientPublicKey`: Buf (size: libsodium._crypto_kx_publickeybytes())
608* `clientSecretKey`: Buf (size: libsodium._crypto_kx_secretkeybytes())
609* `serverPublicKey`: Buf (size: libsodium._crypto_kx_publickeybytes())
610
611__Outputs:__
612* `sharedRx`: Buf (size: libsodium._crypto_kx_sessionkeybytes())
613* `sharedTx`: Buf (size: libsodium._crypto_kx_sessionkeybytes())
614
615
616## crypto_kx_keypair
617Function
618
619__Parameters:__
620
621__Outputs:__
622* `publicKey`: Buf (size: libsodium._crypto_kx_publickeybytes())
623* `privateKey`: Buf (size: libsodium._crypto_kx_secretkeybytes())
624
625
626## crypto_kx_seed_keypair
627Function
628
629__Parameters:__
630* `seed`: Buf (size: libsodium._crypto_kx_seedbytes())
631
632__Outputs:__
633* `publicKey`: Buf (size: libsodium._crypto_kx_publickeybytes())
634* `privateKey`: Buf (size: libsodium._crypto_kx_secretkeybytes())
635
636
637## crypto_kx_server_session_keys
638Function
639
640__Parameters:__
641* `serverPublicKey`: Buf (size: libsodium._crypto_kx_publickeybytes())
642* `serverSecretKey`: Buf (size: libsodium._crypto_kx_secretkeybytes())
643* `clientPublicKey`: Buf (size: libsodium._crypto_kx_publickeybytes())
644
645__Outputs:__
646* `sharedRx`: Buf (size: libsodium._crypto_kx_sessionkeybytes())
647* `sharedTx`: Buf (size: libsodium._crypto_kx_sessionkeybytes())
648
649
650## crypto_onetimeauth
651Function
652
653__Parameters:__
654* `message`: Unsized buf
655* `key`: Buf (size: libsodium._crypto_onetimeauth_keybytes())
656
657__Outputs:__
658* `hash`: Buf (size: libsodium._crypto_onetimeauth_bytes())
659
660
661## crypto_onetimeauth_final
662Function
663
664__Parameters:__
665* `state_address`: OneTimeAuth state address
666
667__Outputs:__
668* `hash`: Buf (size: libsodium._crypto_onetimeauth_bytes())
669
670
671## crypto_onetimeauth_init
672Function
673
674__Parameters:__
675* `key`: Optional unsized buf
676
677__Outputs:__
678* `state`: OneTimeAuth state
679
680
681## crypto_onetimeauth_keygen
682Function
683
684__Parameters:__
685
686__Outputs:__
687* `output`: Buf (size: libsodium._crypto_onetimeauth_keybytes())
688
689
690## crypto_onetimeauth_update
691Function
692
693__Parameters:__
694* `state_address`: OneTimeAuth state address
695* `message_chunk`: Unsized buf
696
697__Outputs:__
698Boolean. True if method executed with success; false otherwise
699
700
701## crypto_onetimeauth_verify
702Function
703
704__Parameters:__
705* `hash`: Buf (size: libsodium._crypto_onetimeauth_bytes())
706* `message`: Unsized buf
707* `key`: Buf (size: libsodium._crypto_onetimeauth_keybytes())
708
709__Outputs:__
710Boolean. True if method executed with success; false otherwise
711
712
713## crypto_pwhash
714Function
715
716__Parameters:__
717* `keyLength`: Unsigned Integer
718* `password`: Unsized buf
719* `salt`: Buf (size: libsodium._crypto_pwhash_saltbytes())
720* `opsLimit`: Unsigned Integer
721* `memLimit`: Unsigned Integer
722* `algorithm`: Unsigned Integer
723
724__Outputs:__
725* `derivedKey`: Buf (size: keyLength)
726
727
728## crypto_pwhash_scryptsalsa208sha256
729Function
730
731__Parameters:__
732* `keyLength`: Unsigned Integer
733* `password`: Unsized buf
734* `salt`: Buf (size: libsodium._crypto_pwhash_scryptsalsa208sha256_saltbytes())
735* `opsLimit`: Unsigned Integer
736* `memLimit`: Unsigned Integer
737
738__Outputs:__
739* `derivedKey`: Buf (size: keyLength)
740
741
742## crypto_pwhash_scryptsalsa208sha256_ll
743Function
744
745__Parameters:__
746* `password`: Unsized buf
747* `salt`: Unsized buf
748* `opsLimit`: Unsigned Integer
749* `r`: Unsigned Integer
750* `p`: Unsigned Integer
751* `keyLength`: Unsigned Integer
752
753__Outputs:__
754* `derivedKey`: Buf (size: keyLength)
755
756
757## crypto_pwhash_scryptsalsa208sha256_str
758Function
759
760__Parameters:__
761* `password`: Unsized buf
762* `opsLimit`: Unsigned Integer
763* `memLimit`: Unsigned Integer
764
765__Outputs:__
766* `hashed_password`: Buf (size: libsodium._crypto_pwhash_scryptsalsa208sha256_strbytes())
767
768
769## crypto_pwhash_scryptsalsa208sha256_str_verify
770Function
771
772__Parameters:__
773* `hashed_password`: A string
774* `password`: Unsized buf
775
776__Outputs:__
777Boolean. True if method executed with success; false otherwise
778
779
780## crypto_pwhash_str
781Function
782
783__Parameters:__
784* `password`: Unsized buf
785* `opsLimit`: Unsigned Integer
786* `memLimit`: Unsigned Integer
787
788__Outputs:__
789* `hashed_password`: Buf (size: libsodium._crypto_pwhash_strbytes())
790
791
792## crypto_pwhash_str_verify
793Function
794
795__Parameters:__
796* `hashed_password`: A string
797* `password`: Unsized buf
798
799__Outputs:__
800Boolean. True if method executed with success; false otherwise
801
802
803## crypto_scalarmult
804Function
805
806__Parameters:__
807* `privateKey`: Buf (size: libsodium._crypto_scalarmult_scalarbytes())
808* `publicKey`: Buf (size: libsodium._crypto_scalarmult_scalarbytes())
809
810__Outputs:__
811* `sharedSecret`: Buf (size: libsodium._crypto_scalarmult_bytes())
812
813
814## crypto_scalarmult_base
815Function
816
817__Parameters:__
818* `privateKey`: Buf (size: libsodium._crypto_scalarmult_scalarbytes())
819
820__Outputs:__
821* `publicKey`: Buf (size: libsodium._crypto_scalarmult_scalarbytes())
822
823
824## crypto_secretbox_detached
825Function
826
827__Parameters:__
828* `message`: Unsized buf
829* `nonce`: Buf (size: libsodium._crypto_secretbox_noncebytes())
830* `key`: Buf (size: libsodium._crypto_secretbox_keybytes())
831
832__Outputs:__
833* `cipher`: Buf (size: message_length)
834* `mac`: Buf (size: libsodium._crypto_secretbox_macbytes())
835
836
837## crypto_secretbox_easy
838Function
839
840__Parameters:__
841* `message`: Unsized buf
842* `nonce`: Buf (size: libsodium._crypto_secretbox_noncebytes())
843* `key`: Buf (size: libsodium._crypto_secretbox_keybytes())
844
845__Outputs:__
846* `cipher`: Buf (size: message_length + libsodium._crypto_secretbox_macbytes())
847
848
849## crypto_secretbox_keygen
850Function
851
852__Parameters:__
853
854__Outputs:__
855* `output`: Buf (size: libsodium._crypto_secretbox_keybytes())
856
857
858## crypto_secretbox_open_detached
859Function
860
861__Parameters:__
862* `ciphertext`: Unsized buf
863* `mac`: Buf (size: libsodium._crypto_secretbox_macbytes())
864* `nonce`: Buf (size: libsodium._crypto_secretbox_noncebytes())
865* `key`: Buf (size: libsodium._crypto_secretbox_keybytes())
866
867__Outputs:__
868* `message`: Buf (size: ciphertext_length)
869
870
871## crypto_secretbox_open_easy
872Function
873
874__Parameters:__
875* `ciphertext`: Minsized buf
876* `nonce`: Buf (size: libsodium._crypto_secretbox_noncebytes())
877* `key`: Buf (size: libsodium._crypto_secretbox_keybytes())
878
879__Outputs:__
880* `message`: Buf (size: ciphertext_length - libsodium._crypto_secretbox_macbytes())
881
882
883## crypto_secretstream_xchacha20poly1305_init_pull
884Function
885
886__Parameters:__
887* `header`: Buf (size: libsodium._crypto_secretstream_xchacha20poly1305_headerbytes())
888* `key`: Buf (size: libsodium._crypto_secretstream_xchacha20poly1305_keybytes())
889
890__Outputs:__
891* `state`: Secretstream XChaCha20Poly1305 state
892
893
894## crypto_secretstream_xchacha20poly1305_init_push
895Function
896
897__Parameters:__
898* `key`: Buf (size: libsodium._crypto_secretstream_xchacha20poly1305_keybytes())
899
900__Outputs:__
901* `state`: Secretstream XChaCha20Poly1305 state
902* `header`: Buf (size: libsodium._crypto_secretstream_xchacha20poly1305_headerbytes())
903
904
905## crypto_secretstream_xchacha20poly1305_keygen
906Function
907
908__Parameters:__
909
910__Outputs:__
911* `output`: Buf (size: libsodium._crypto_secretstream_xchacha20poly1305_keybytes())
912
913
914## crypto_secretstream_xchacha20poly1305_pull
915Function
916
917__Parameters:__
918* `state_address`: Secretstream XChaCha20Poly1305 state address
919* `cipher`: Minsized buf
920* `ad`: Optional unsized buf
921
922__Outputs:__
923* `message_chunk`: Buf (size: cipher_length - libsodium._crypto_secretstream_xchacha20poly1305_abytes())
924
925
926## crypto_secretstream_xchacha20poly1305_push
927Function
928
929__Parameters:__
930* `state_address`: Secretstream XChaCha20Poly1305 state address
931* `message_chunk`: Unsized buf
932* `ad`: Optional unsized buf
933* `tag`: Unsigned Integer
934
935__Outputs:__
936* `cipher`: Buf (size: message_chunk_length + libsodium._crypto_secretstream_xchacha20poly1305_abytes())
937
938
939## crypto_secretstream_xchacha20poly1305_rekey
940Function
941
942__Parameters:__
943* `state_address`: Secretstream XChaCha20Poly1305 state address
944
945__Outputs:__
946Boolean. True if method executed with success; false otherwise
947
948
949## crypto_shorthash
950Function
951
952__Parameters:__
953* `message`: Unsized buf
954* `key`: Buf (size: libsodium._crypto_shorthash_keybytes())
955
956__Outputs:__
957* `hash`: Buf (size: libsodium._crypto_shorthash_bytes())
958
959
960## crypto_shorthash_keygen
961Function
962
963__Parameters:__
964
965__Outputs:__
966* `output`: Buf (size: libsodium._crypto_shorthash_keybytes())
967
968
969## crypto_shorthash_siphashx24
970Function
971
972__Parameters:__
973* `message`: Unsized buf
974* `key`: Buf (size: libsodium._crypto_shorthash_siphashx24_keybytes())
975
976__Outputs:__
977* `hash`: Buf (size: libsodium._crypto_shorthash_siphashx24_bytes())
978
979
980## crypto_sign
981Function
982
983__Parameters:__
984* `message`: Unsized buf
985* `privateKey`: Buf (size: libsodium._crypto_sign_secretkeybytes())
986
987__Outputs:__
988* `signature`: Buf (size: message.length + libsodium._crypto_sign_bytes())
989
990
991## crypto_sign_detached
992Function
993
994__Parameters:__
995* `message`: Unsized buf
996* `privateKey`: Buf (size: libsodium._crypto_sign_secretkeybytes())
997
998__Outputs:__
999* `signature`: Buf (size: libsodium._crypto_sign_bytes())
1000
1001
1002## crypto_sign_ed25519_pk_to_curve25519
1003Function
1004
1005__Parameters:__
1006* `edPk`: Buf (size: libsodium._crypto_sign_publickeybytes())
1007
1008__Outputs:__
1009* `cPk`: Buf (size: libsodium._crypto_scalarmult_scalarbytes())
1010
1011
1012## crypto_sign_ed25519_sk_to_curve25519
1013Function
1014
1015__Parameters:__
1016* `edSk`: Buf (size: libsodium._crypto_sign_secretkeybytes())
1017
1018__Outputs:__
1019* `cSk`: Buf (size: libsodium._crypto_scalarmult_scalarbytes())
1020
1021
1022## crypto_sign_ed25519_sk_to_pk
1023Function
1024
1025__Parameters:__
1026* `privateKey`: Buf (size: libsodium._crypto_sign_secretkeybytes())
1027
1028__Outputs:__
1029* `publicKey`: Buf (size: libsodium._crypto_sign_publickeybytes())
1030
1031
1032## crypto_sign_ed25519_sk_to_seed
1033Function
1034
1035__Parameters:__
1036* `privateKey`: Buf (size: libsodium._crypto_sign_secretkeybytes())
1037
1038__Outputs:__
1039* `seed`: Buf (size: libsodium._crypto_sign_seedbytes())
1040
1041
1042## crypto_sign_final_create
1043Function
1044
1045__Parameters:__
1046* `state_address`: Signature state address
1047* `privateKey`: Buf (size: libsodium._crypto_sign_secretkeybytes())
1048
1049__Outputs:__
1050* `signature`: Buf (size: libsodium._crypto_sign_bytes())
1051
1052
1053## crypto_sign_final_verify
1054Function
1055
1056__Parameters:__
1057* `state_address`: Signature state address
1058* `signature`: Buf (size: libsodium._crypto_sign_bytes())
1059* `publicKey`: Buf (size: libsodium._crypto_sign_publickeybytes())
1060
1061__Outputs:__
1062Boolean. True if method executed with success; false otherwise
1063
1064
1065## crypto_sign_init
1066Function
1067
1068__Parameters:__
1069
1070__Outputs:__
1071* `state`: Signature state
1072
1073
1074## crypto_sign_keypair
1075Function
1076
1077__Parameters:__
1078
1079__Outputs:__
1080* `publicKey`: Buf (size: libsodium._crypto_sign_publickeybytes())
1081* `privateKey`: Buf (size: libsodium._crypto_sign_secretkeybytes())
1082
1083
1084## crypto_sign_open
1085Function
1086
1087__Parameters:__
1088* `signedMessage`: Minsized buf
1089* `publicKey`: Buf (size: libsodium._crypto_sign_publickeybytes())
1090
1091__Outputs:__
1092* `message`: Buf (size: signedMessage_length - libsodium._crypto_sign_bytes())
1093
1094
1095## crypto_sign_seed_keypair
1096Function
1097
1098__Parameters:__
1099* `seed`: Buf (size: libsodium._crypto_sign_seedbytes())
1100
1101__Outputs:__
1102* `publicKey`: Buf (size: libsodium._crypto_sign_publickeybytes())
1103* `privateKey`: Buf (size: libsodium._crypto_sign_secretkeybytes())
1104
1105
1106## crypto_sign_update
1107Function
1108
1109__Parameters:__
1110* `state_address`: Signature state address
1111* `message_chunk`: Unsized buf
1112
1113__Outputs:__
1114Boolean. True if method executed with success; false otherwise
1115
1116
1117## crypto_sign_verify_detached
1118Function
1119
1120__Parameters:__
1121* `signature`: Buf (size: libsodium._crypto_sign_bytes())
1122* `message`: Unsized buf
1123* `publicKey`: Buf (size: libsodium._crypto_sign_publickeybytes())
1124
1125__Outputs:__
1126Boolean. True if method executed with success; false otherwise
1127
1128
1129## crypto_stream_chacha20
1130Function
1131
1132__Parameters:__
1133* `outLength`: Unsigned Integer
1134* `key`: Buf (size: libsodium._crypto_stream_chacha20_keybytes())
1135* `nonce`: Buf (size: libsodium._crypto_stream_chacha20_noncebytes())
1136
1137__Outputs:__
1138* `out`: Buf (size: outLength)
1139
1140
1141## crypto_stream_chacha20_ietf_xor
1142Function
1143
1144__Parameters:__
1145* `input_message`: Unsized buf
1146* `nonce`: Buf (size: libsodium._crypto_stream_chacha20_ietf_noncebytes())
1147* `key`: Buf (size: libsodium._crypto_stream_chacha20_ietf_keybytes())
1148
1149__Outputs:__
1150* `output_message`: Buf (size: input_message_length)
1151
1152
1153## crypto_stream_chacha20_ietf_xor_ic
1154Function
1155
1156__Parameters:__
1157* `input_message`: Unsized buf
1158* `nonce`: Buf (size: libsodium._crypto_stream_chacha20_ietf_noncebytes())
1159* `nonce_increment`: Unsigned Integer
1160* `key`: Buf (size: libsodium._crypto_stream_chacha20_ietf_keybytes())
1161
1162__Outputs:__
1163* `output_message`: Buf (size: input_message_length)
1164
1165
1166## crypto_stream_chacha20_keygen
1167Function
1168
1169__Parameters:__
1170
1171__Outputs:__
1172* `output`: Buf (size: libsodium._crypto_stream_chacha20_keybytes())
1173
1174
1175## crypto_stream_chacha20_xor
1176Function
1177
1178__Parameters:__
1179* `input_message`: Unsized buf
1180* `nonce`: Buf (size: libsodium._crypto_stream_chacha20_noncebytes())
1181* `key`: Buf (size: libsodium._crypto_stream_chacha20_keybytes())
1182
1183__Outputs:__
1184* `output_message`: Buf (size: input_message_length)
1185
1186
1187## crypto_stream_chacha20_xor_ic
1188Function
1189
1190__Parameters:__
1191* `input_message`: Unsized buf
1192* `nonce`: Buf (size: libsodium._crypto_stream_chacha20_noncebytes())
1193* `nonce_increment`: Unsigned Integer
1194* `key`: Buf (size: libsodium._crypto_stream_chacha20_keybytes())
1195
1196__Outputs:__
1197* `output_message`: Buf (size: input_message_length)
1198
1199
1200## crypto_stream_keygen
1201Function
1202
1203__Parameters:__
1204
1205__Outputs:__
1206* `output`: Buf (size: libsodium._crypto_stream_keybytes())
1207
1208
1209## crypto_stream_xchacha20_keygen
1210Function
1211
1212__Parameters:__
1213
1214__Outputs:__
1215* `output`: Buf (size: libsodium._crypto_stream_xchacha20_keybytes())
1216
1217
1218## crypto_stream_xchacha20_xor
1219Function
1220
1221__Parameters:__
1222* `input_message`: Unsized buf
1223* `nonce`: Buf (size: libsodium._crypto_stream_xchacha20_noncebytes())
1224* `key`: Buf (size: libsodium._crypto_stream_xchacha20_keybytes())
1225
1226__Outputs:__
1227* `output_message`: Buf (size: input_message_length)
1228
1229
1230## crypto_stream_xchacha20_xor_ic
1231Function
1232
1233__Parameters:__
1234* `input_message`: Unsized buf
1235* `nonce`: Buf (size: libsodium._crypto_stream_xchacha20_noncebytes())
1236* `nonce_increment`: Unsigned Integer
1237* `key`: Buf (size: libsodium._crypto_stream_xchacha20_keybytes())
1238
1239__Outputs:__
1240* `output_message`: Buf (size: input_message_length)
1241
1242
1243## randombytes_buf
1244Function
1245
1246__Parameters:__
1247* `length`: Unsigned Integer
1248
1249__Outputs:__
1250* `output`: Buf (size: length)
1251
1252
1253## randombytes_buf_deterministic
1254Function
1255
1256__Parameters:__
1257* `length`: Unsigned Integer
1258* `seed`: Buf (size: libsodium._randombytes_seedbytes())
1259
1260__Outputs:__
1261* `output`: Buf (size: length)
1262
1263
1264## randombytes_close
1265Function
1266
1267__Parameters:__
1268
1269__Outputs:__
1270Boolean. True if method executed with success; false otherwise
1271
1272
1273## randombytes_random
1274Function
1275
1276__Parameters:__
1277
1278__Outputs:__
1279Boolean. True if method executed with success; false otherwise
1280
1281
1282## randombytes_set_implementation
1283Function
1284
1285__Parameters:__
1286* `implementation`: Randombytes implementation
1287
1288__Outputs:__
1289Boolean. True if method executed with success; false otherwise
1290
1291
1292## randombytes_stir
1293Function
1294
1295__Parameters:__
1296
1297__Outputs:__
1298Boolean. True if method executed with success; false otherwise
1299
1300
1301## randombytes_uniform
1302Function
1303
1304__Parameters:__
1305* `upper_bound`: Unsigned Integer
1306
1307__Outputs:__
1308Boolean. True if method executed with success; false otherwise
1309
1310
1311## sodium_version_string
1312Function
1313
1314__Parameters:__
1315
1316__Outputs:__
1317Boolean. True if method executed with success; false otherwise
1318
1319
1320