Digital Signature: Sign & Verify
flowchart LR
subgraph signer ["Signer's machine"]
direction TB
M["Message M"]:::plainNode
SH["Hash function
SHA-256"]:::hashNode HM["Digest H(M)"]:::digestNode SK["Sign with PRIVATE key"]:::keyNode S["Signature S"]:::sigNode SEND["Send (M, S)"]:::plainNode M --> SH --> HM --> SK --> S --> SEND end subgraph verifier ["Verifier's machine"] direction TB RECV["Receive (M, S)"]:::plainNode VH["Hash function
SHA-256"]:::hashNode VHM["Computed digest H(M)"]:::digestNode VP["Verify S with PUBLIC key"]:::keyNode VEX["Expected digest"]:::digestNode EQ{"Equal?"}:::decisionNode OK["Valid signature ✓"]:::okNode BAD["Tampered or wrong key ✗"]:::badNode RECV --> VH --> VHM --> EQ RECV --> VP --> VEX --> EQ EQ -- yes --> OK EQ -- no --> BAD end SEND == across trust boundary ==> RECV classDef plainNode fill:#ffffff,stroke:#455a64,stroke-width:2px,color:#212529,font-size:14px classDef hashNode fill:#1565c0,stroke:#0d47a1,stroke-width:2px,color:#ffffff,font-size:14px classDef digestNode fill:#455a64,stroke:#263238,stroke-width:2px,color:#ffffff,font-size:14px classDef keyNode fill:#1565c0,stroke:#0d47a1,stroke-width:2px,color:#ffffff,font-size:14px classDef sigNode fill:#d84315,stroke:#bf360c,stroke-width:2px,color:#ffffff,font-size:14px classDef decisionNode fill:#fff8e1,stroke:#ffa000,stroke-width:2px,color:#212529,font-size:14px classDef okNode fill:#2e7d32,stroke:#1b5e20,stroke-width:2px,color:#ffffff,font-size:14px classDef badNode fill:#c62828,stroke:#8e0000,stroke-width:2px,color:#ffffff,font-size:14px linkStyle default stroke:#90a4ae,stroke-width:2px,font-size:13px
SHA-256"]:::hashNode HM["Digest H(M)"]:::digestNode SK["Sign with PRIVATE key"]:::keyNode S["Signature S"]:::sigNode SEND["Send (M, S)"]:::plainNode M --> SH --> HM --> SK --> S --> SEND end subgraph verifier ["Verifier's machine"] direction TB RECV["Receive (M, S)"]:::plainNode VH["Hash function
SHA-256"]:::hashNode VHM["Computed digest H(M)"]:::digestNode VP["Verify S with PUBLIC key"]:::keyNode VEX["Expected digest"]:::digestNode EQ{"Equal?"}:::decisionNode OK["Valid signature ✓"]:::okNode BAD["Tampered or wrong key ✗"]:::badNode RECV --> VH --> VHM --> EQ RECV --> VP --> VEX --> EQ EQ -- yes --> OK EQ -- no --> BAD end SEND == across trust boundary ==> RECV classDef plainNode fill:#ffffff,stroke:#455a64,stroke-width:2px,color:#212529,font-size:14px classDef hashNode fill:#1565c0,stroke:#0d47a1,stroke-width:2px,color:#ffffff,font-size:14px classDef digestNode fill:#455a64,stroke:#263238,stroke-width:2px,color:#ffffff,font-size:14px classDef keyNode fill:#1565c0,stroke:#0d47a1,stroke-width:2px,color:#ffffff,font-size:14px classDef sigNode fill:#d84315,stroke:#bf360c,stroke-width:2px,color:#ffffff,font-size:14px classDef decisionNode fill:#fff8e1,stroke:#ffa000,stroke-width:2px,color:#212529,font-size:14px classDef okNode fill:#2e7d32,stroke:#1b5e20,stroke-width:2px,color:#ffffff,font-size:14px classDef badNode fill:#c62828,stroke:#8e0000,stroke-width:2px,color:#ffffff,font-size:14px linkStyle default stroke:#90a4ae,stroke-width:2px,font-size:13px
Color Key
Hash / key operation
Message digest
Signature
Valid / Invalid
Key asymmetry
PRIVATE key — only the signer holds it; it produces the signature.PUBLIC key — anyone can hold it; it only verifies the signature.
Step Details
Hover or tap a box to see what happens at each step of signing and verifying.