No, it doesn't add a prefix.
But signing messages and transactions do use separate functions.
The Signer interface is defined as:
export interface Signer
* @description signs an extrinsic payload from a serialized form
signPayload?: (payload: SignerPayloadJSON) => Promise<SignerResult>;
* @description signs a raw payload, only the bytes data as supplied
signRaw?: (raw: SignerPayloadRaw) => Promise<SignerResult>;
* @description Receives an update for the extrinsic signed by a `signer.sign`
update?: (id: number, status: H256 | ISubmittableResult) => void;
When signing messages,
signRaw is called. When signing transactions,
signPayload is used.
If you call
alice.sign('a') to sign a message, the payload would always be like
But the result will vary each time you call it, because in sr25519 signatures are non-deterministic.
When you call
await api.tx.system.remark('a'), the payload will be like
The two types of payloads are not compatible with each other. Therefore you cannot send a spoofed transaction that way.