ELGAMAL(3)
ELGAMAL(3) π β¨
Welcome to the Library Functions Manual page for ELGAMAL(3), bestie β itβs giving cryptography, and weβre gonna make it make sense. No cap.
πΈ NAME πΈ
eggen, egencrypt, egdecrypt, egsign, egverify, egpuballoc, egpubfree, egprivalloc, egprivfree, egsigalloc, egsigfree, egprivtopub β elgamal encryption.
β¨ SYNOPSIS β¨
Okay so hereβs the exact sig, character-for-character, no edits:
#include <u.h>
#include <libc.h>
#include <mp.h>
#include <libsec.h>
EGpriv* eggen(int nlen, int nrep)
mpint* egencrypt(EGpub *k, mpint *in, mpint *out)
mpint* egdecrypt(EGpriv *k, mpint *in, mpint *out)
EGsig* egsign(EGpriv *k, mpint *m)
int egverify(EGpub *k, EGsig *sig, mpint *m)
EGpub* egpuballoc(void)
void egpubfree(EGpub*)
EGpriv* egprivalloc(void)
void egprivfree(EGpriv*)
EGsig* egsigalloc(void)
void egsigfree(EGsig*)
EGpub* egprivtopub(EGpriv*)
π¦ DESCRIPTION π¦
Elgamal is a public key encryption and signature algorithm. The owner of a key publishes the public part of the key:
struct EGpub
{
mpint *p; // modulus
mpint *alpha; // generator
mpint *key; // (encryption key) alpha**secret mod p
};
This part can be used for encrypting data (with egencrypt) to be sent to the owner. The owner decrypts (with egdecrypt) using his private key:
struct EGpriv
{
EGpub pub;
mpint *secret; // (decryption key)
};
Keys are generated using eggen. eggen takes both the bit length of the modulus and the number of repetitions of the Miller-Rabin primality test to run. If the latter is 0, it does the default number of rounds. egprivtopub returns a newly allocated copy of the public key corresponding to the private key.
The routines egpuballoc, egpubfree, egprivalloc, and egprivfree are provided to manage key storage.
egsign signs message m using a private key k, yielding a:
struct EGsig
{
mpint *r, *s;
};
egverify returns 0 if the signature is valid and -1 if not.
Bestie, thatβs the whole vibe check:0= valid,-1= not valid. Periodt.
The routines egsigalloc and egsigfree are provided to manage signature storage.
π SOURCE π
/src/libsec
π SEE ALSO π
Source/version check, bestie: the SOURCE is /src/libsec, and the footer is just ELGAMAL(3) with no date shown β thatβs the whole cute sign-off. Stay iconic and encrypted πβ¨
π¦ where this page comes from
- alpine 3.24: plan9port-doc 0_git20260208-r0 Β· LPL-1.02
- arch rolling: plan9port 20261021-2 Β· custom
- nixos 26.05: plan9port 0-unstable-2025-11-10
- nixos 26.05: plan9port-wayland 0-unstable-2025-11-26
- nixpkgs unstable: plan9port 0-unstable-2025-11-10
- nixpkgs unstable: plan9port-wayland 0-unstable-2025-11-26
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms